Don't use len(SEQUENCE) as condition value (#7249)

* Don't use len(SEQUENCE) as condition value

* Update volvooncall.py
This commit is contained in:
Fabian Affolter authored and Paulus Schoutsen committed 2017-04-23 20:41:09 -07:00
1 parent 15b2473224
commit cfc023e128
43 files changed
+319 -355

No files matched your search

@@ -31,7 +31,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
conf_switches = config_from_file(hass.config.path(
INSTEON_LOCAL_SWITCH_CONF))
if len(conf_switches):
if conf_switches:
for device_id in conf_switches:
setup_switch(
device_id, conf_switches[device_id], insteonhub, hass,
@@ -48,8 +48,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
hass, add_devices)
def request_configuration(device_id, insteonhub, model, hass,
add_devices_callback):
def request_configuration(
device_id, insteonhub, model, hass, add_devices_callback):
"""Request configuration steps from the user."""
configurator = get_component('configurator')
@@ -81,7 +81,7 @@ def setup_switch(device_id, name, insteonhub, hass, add_devices_callback):
request_id = _CONFIGURING.pop(device_id)
configurator = get_component('configurator')
configurator.request_done(request_id)
_LOGGER.info("Device configuration done!")
_LOGGER.info("Device configuration done")
conf_switch = config_from_file(hass.config.path(INSTEON_LOCAL_SWITCH_CONF))
if device_id not in conf_switch:
+10 -9
View File
@@ -24,12 +24,12 @@ SWITCH_TYPES = {
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Neato switches."""
"""Set up the Neato switches."""
dev = []
for robot in hass.data[NEATO_ROBOTS]:
for type_name in SWITCH_TYPES:
dev.append(NeatoConnectedSwitch(hass, robot, type_name))
_LOGGER.debug('Adding switches %s', dev)
_LOGGER.debug("Adding switches %s", dev)
add_devices(dev)
@@ -41,25 +41,26 @@ class NeatoConnectedSwitch(ToggleEntity):
self.type = switch_type
self.robot = robot
self.neato = hass.data[NEATO_LOGIN]
self._robot_name = self.robot.name + ' ' + SWITCH_TYPES[self.type][0]
self._robot_name = '{} {}'.format(
self.robot.name, SWITCH_TYPES[self.type][0])
try:
self._state = self.robot.state
except (requests.exceptions.ConnectionError,
requests.exceptions.HTTPError) as ex:
_LOGGER.warning('Neato connection error: %s', ex)
_LOGGER.warning("Neato connection error: %s", ex)
self._state = None
self._schedule_state = None
self._clean_state = None
def update(self):
"""Update the states of Neato switches."""
_LOGGER.debug('Running switch update')
_LOGGER.debug("Running switch update")
self.neato.update_robots()
try:
self._state = self.robot.state
except (requests.exceptions.ConnectionError,
requests.exceptions.HTTPError) as ex:
_LOGGER.warning('Neato connection error: %s', ex)
_LOGGER.warning("Neato connection error: %s", ex)
self._state = None
return
_LOGGER.debug('self._state=%s', self._state)
@@ -71,14 +72,14 @@ class NeatoConnectedSwitch(ToggleEntity):
self._clean_state = STATE_ON
else:
self._clean_state = STATE_OFF
_LOGGER.debug('schedule_state=%s', self._schedule_state)
_LOGGER.debug("Schedule state: %s", self._schedule_state)
if self.type == SWITCH_TYPE_SCHEDULE:
_LOGGER.debug('self._state=%s', self._state)
_LOGGER.debug("State: %s", self._state)
if self.robot.schedule_enabled:
self._schedule_state = STATE_ON
else:
self._schedule_state = STATE_OFF
_LOGGER.debug('schedule_state=%s', self._schedule_state)
_LOGGER.debug("Shedule state: %s", self._schedule_state)
@property
def name(self):
+3 -3
View File
@@ -58,14 +58,14 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
password = config.get(CONF_PASSWORD)
port = config.get(CONF_PORT)
if len(DEVICES) == 0:
if not DEVICES:
hass.http.register_view(NetioApiView)
dev = Netio(host, port, username, password)
DEVICES[host] = Device(dev, [])
# Throttle the update for all NetioSwitches of one Netio
# Throttle the update for all Netio switches of one Netio
dev.update = util.Throttle(MIN_TIME_BETWEEN_SCANS)(dev.update)
for key in config[CONF_OUTLETS]:
@@ -123,7 +123,7 @@ class NetioApiView(HomeAssistantView):
class NetioSwitch(SwitchDevice):
"""Provide a netio linked switch."""
"""Provide a Netio linked switch."""
def __init__(self, netio, outlet, name):
"""Defined to handle throttle."""