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:
1 parent
e6ece4bf6d
commit
9f2aae1357
28 files changed
+272
-271
No files matched your search
@@ -15,18 +15,17 @@ from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA)
|
||||
from homeassistant.const import (CONF_HOST, CONF_PASSWORD, CONF_USERNAME)
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
|
||||
REQUIREMENTS = ['https://github.com/mweinelt/anel-pwrctrl/archive/'
|
||||
'ed26e8830e28a2bfa4260a9002db23ce3e7e63d7.zip'
|
||||
'#anel_pwrctrl==0.0.1']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_PORT_RECV = "port_recv"
|
||||
CONF_PORT_SEND = "port_send"
|
||||
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=5)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_PORT_RECV): cv.port,
|
||||
vol.Required(CONF_PORT_SEND): cv.port,
|
||||
@@ -48,13 +47,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
from anel_pwrctrl import DeviceMaster
|
||||
|
||||
try:
|
||||
master = DeviceMaster(username=username,
|
||||
password=password,
|
||||
read_port=port_send,
|
||||
write_port=port_recv)
|
||||
master = DeviceMaster(
|
||||
username=username, password=password, read_port=port_send,
|
||||
write_port=port_recv)
|
||||
master.query(ip_addr=host)
|
||||
except socket.error as ex:
|
||||
_LOGGER.error('Unable to discover PwrCtrl device: %s', str(ex))
|
||||
_LOGGER.error("Unable to discover PwrCtrl device: %s", str(ex))
|
||||
return False
|
||||
|
||||
devices = []
|
||||
@@ -84,7 +82,7 @@ class PwrCtrlSwitch(SwitchDevice):
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique ID of the device."""
|
||||
return "{device}-{switch_idx}".format(
|
||||
return '{device}-{switch_idx}'.format(
|
||||
device=self._port.device.host,
|
||||
switch_idx=self._port.get_index()
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user