Maintenance 2nd (#4106)

* Add link to docs

* Fix link

* Update line breaks

* Update ordering

* Align vera platofrm to only use add_devices
(instead od add_devices_callback)

* Remove line break

* Use consts

* Update ordering

* Update ordering

* Use const, create default name, use string formatting

* Update ordering

* Use const

* Update import style

* Update ordering and line breaks

* update line breaks

* Set default port

* Set defaults and update ordering

* Update ordering

* Minor style updates

* Update ordering, defaults, line breaks, and readability

* Use constants

* Add line breaks

* use string formatting

* Update line breaks

* Update logger
This commit is contained in:
Fabian Affolter authored and GitHub committed 2016-10-30 09:58:34 +01:00
1 parent e6ece4bf6d
commit 9f2aae1357
28 files changed
+272 -271

No files matched your search

@@ -30,13 +30,13 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
})
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Add wake on lan switch."""
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up a wake on lan switch."""
name = config.get(CONF_NAME)
host = config.get(CONF_HOST)
mac_address = config.get(CONF_MAC_ADDRESS)
add_devices_callback([WOLSwitch(hass, name, host, mac_address)])
add_devices([WOLSwitch(hass, name, host, mac_address)])
class WOLSwitch(SwitchDevice):
@@ -79,13 +79,12 @@ class WOLSwitch(SwitchDevice):
def update(self):
"""Check if device is on and update the state."""
if platform.system().lower() == "windows":
ping_cmd = "ping -n 1 -w {} {}"\
.format(DEFAULT_PING_TIMEOUT * 1000, self._host)
if platform.system().lower() == 'windows':
ping_cmd = 'ping -n 1 -w {} {}'.format(
DEFAULT_PING_TIMEOUT * 1000, self._host)
else:
ping_cmd = "ping -c 1 -W {} {}"\
.format(DEFAULT_PING_TIMEOUT, self._host)
ping_cmd = 'ping -c 1 -W {} {}'.format(
DEFAULT_PING_TIMEOUT, self._host)
status = sp.getstatusoutput(ping_cmd)[0]
self._state = not bool(status)