From 32f1791c5ae50ba5ff2fcad3b4c614f7ae07ed12 Mon Sep 17 00:00:00 2001 From: badele Date: Tue, 6 Oct 2015 08:44:15 +0200 Subject: [PATCH] Check flake & pylint style --- homeassistant/components/light/rfxtrx.py | 15 ++++++++------- homeassistant/components/rfxtrx.py | 15 ++++++--------- homeassistant/components/switch/rfxtrx.py | 21 +++++++++++---------- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/homeassistant/components/light/rfxtrx.py b/homeassistant/components/light/rfxtrx.py index d4008682c4c..7c8bdb7a93a 100644 --- a/homeassistant/components/light/rfxtrx.py +++ b/homeassistant/components/light/rfxtrx.py @@ -45,7 +45,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): for entity_id, entity_info in devices.items(): if entity_id not in rfxtrx.RFX_DEVICES: _LOGGER.info("Add %s rfxtrx.light", entity_info['name']) - rfxobject = rfxtrx.getRFXObject(entity_info['packetid']) + rfxobject = rfxtrx.get_rfx_object(entity_info['packetid']) new_light = RfxtrxLight(entity_info['name'], rfxobject, False) rfxtrx.RFX_DEVICES[entity_id] = new_light lights.append(new_light) @@ -61,13 +61,14 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): if entity_id not in rfxtrx.RFX_DEVICES: automatic_add = config.get('automatic_add', False) if automatic_add: - _LOGGER.info("Automatic add %s rfxtrx.light (class: %s subtype: %s)", - entity_id, - event.device.__class__.__name__, - event.device.subtype + _LOGGER.info( + "Automatic add %s rfxtrx.light (Class: %s Sub: %s)", + entity_id, + event.device.__class__.__name__, + event.device.subtype ) - packet_id = "".join("{0:02x}".format(x) for x in event.data) - entity_name = "%(entity_id)s : %(packet_id)s" % locals() + pkt_id = "".join("{0:02x}".format(x) for x in event.data) + entity_name = "%s : %s" % (entity_id, pkt_id) new_light = RfxtrxLight(entity_name, event, False) rfxtrx.RFX_DEVICES[entity_id] = new_light add_devices_callback([new_light]) diff --git a/homeassistant/components/rfxtrx.py b/homeassistant/components/rfxtrx.py index 2ec4fd3d25d..0c3f377150b 100644 --- a/homeassistant/components/rfxtrx.py +++ b/homeassistant/components/rfxtrx.py @@ -1,9 +1,3 @@ -""" -homeassistant.components.rfxtrx -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Connects Home Assistant to a RFXtrx device. -""" - """ homeassistant.components.rfxtrx ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -37,6 +31,7 @@ RFX_DEVICES = {} _LOGGER = logging.getLogger(__name__) RFXOBJECT = None + def setup(hass, config): """ Setup the Rfxtrx component. """ @@ -47,8 +42,9 @@ def setup(hass, config): # Log RFXCOM event entity_id = slugify(event.device.id_string.lower()) packet_id = "".join("{0:02x}".format(x) for x in event.data) - entity_name = "%(entity_id)s : %(packet_id)s" % locals() - _LOGGER.info("Receive RFXCOM event from %s => %s" % (event.device, entity_name)) + entity_name = "%s : %s" % (entity_id, packet_id) + _LOGGER.info("Receive RFXCOM event from %s => %s", + event.device, entity_name) # Callback to HA registered components for subscriber in RECEIVED_EVT_SUBSCRIBERS: @@ -74,7 +70,8 @@ def setup(hass, config): return True -def getRFXObject(packetid): + +def get_rfx_object(packetid): """ return the RFXObject with the packetid""" try: import RFXtrx as rfxtrxmod diff --git a/homeassistant/components/switch/rfxtrx.py b/homeassistant/components/switch/rfxtrx.py index d13e298f1b7..7eefc6fb229 100644 --- a/homeassistant/components/switch/rfxtrx.py +++ b/homeassistant/components/switch/rfxtrx.py @@ -46,10 +46,10 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): for entity_id, entity_info in devices.items(): if entity_id not in rfxtrx.RFX_DEVICES: _LOGGER.info("Add %s rfxtrx.switch", entity_info['name']) - rfxobject = rfxtrx.getRFXObject(entity_info['packetid']) - new_switch = RfxtrxSwitch(entity_info['name'], rfxobject, False) - rfxtrx.RFX_DEVICES[entity_id] = new_switch - switchs.append(new_switch) + rfxobject = rfxtrx.get_rfx_object(entity_info['packetid']) + newswitch = RfxtrxSwitch(entity_info['name'], rfxobject, False) + rfxtrx.RFX_DEVICES[entity_id] = newswitch + switchs.append(newswitch) add_devices_callback(switchs) @@ -62,13 +62,14 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): if entity_id not in rfxtrx.RFX_DEVICES: automatic_add = config.get('automatic_add', False) if automatic_add: - _LOGGER.info("Automatic add %s rfxtrx.switch (class: %s subtype: %s)", - entity_id, - event.device.__class__.__name__, - event.device.subtype + _LOGGER.info( + "Automatic add %s rfxtrx.switch (Class: %s Sub: %s)", + entity_id, + event.device.__class__.__name__, + event.device.subtype ) - packet_id = "".join("{0:02x}".format(x) for x in event.data) - entity_name = "%(entity_id)s : %(packet_id)s" % locals() + pkt_id = "".join("{0:02x}".format(x) for x in event.data) + entity_name = "%s : %s" % (entity_id, pkt_id) new_switch = RfxtrxSwitch(entity_name, event, False) rfxtrx.RFX_DEVICES[entity_id] = new_switch add_devices_callback([new_switch])