Check flake & pylint style

This commit is contained in:
badele 2015-10-06 08:44:15 +02:00
parent 7f71706f08
commit 32f1791c5a
3 changed files with 25 additions and 26 deletions

View File

@ -45,7 +45,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
for entity_id, entity_info in devices.items(): for entity_id, entity_info in devices.items():
if entity_id not in rfxtrx.RFX_DEVICES: if entity_id not in rfxtrx.RFX_DEVICES:
_LOGGER.info("Add %s rfxtrx.light", entity_info['name']) _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) new_light = RfxtrxLight(entity_info['name'], rfxobject, False)
rfxtrx.RFX_DEVICES[entity_id] = new_light rfxtrx.RFX_DEVICES[entity_id] = new_light
lights.append(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: if entity_id not in rfxtrx.RFX_DEVICES:
automatic_add = config.get('automatic_add', False) automatic_add = config.get('automatic_add', False)
if automatic_add: if automatic_add:
_LOGGER.info("Automatic add %s rfxtrx.light (class: %s subtype: %s)", _LOGGER.info(
entity_id, "Automatic add %s rfxtrx.light (Class: %s Sub: %s)",
event.device.__class__.__name__, entity_id,
event.device.subtype event.device.__class__.__name__,
event.device.subtype
) )
packet_id = "".join("{0:02x}".format(x) for x in event.data) pkt_id = "".join("{0:02x}".format(x) for x in event.data)
entity_name = "%(entity_id)s : %(packet_id)s" % locals() entity_name = "%s : %s" % (entity_id, pkt_id)
new_light = RfxtrxLight(entity_name, event, False) new_light = RfxtrxLight(entity_name, event, False)
rfxtrx.RFX_DEVICES[entity_id] = new_light rfxtrx.RFX_DEVICES[entity_id] = new_light
add_devices_callback([new_light]) add_devices_callback([new_light])

View File

@ -1,9 +1,3 @@
"""
homeassistant.components.rfxtrx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Connects Home Assistant to a RFXtrx device.
"""
""" """
homeassistant.components.rfxtrx homeassistant.components.rfxtrx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -37,6 +31,7 @@ RFX_DEVICES = {}
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
RFXOBJECT = None RFXOBJECT = None
def setup(hass, config): def setup(hass, config):
""" Setup the Rfxtrx component. """ """ Setup the Rfxtrx component. """
@ -47,8 +42,9 @@ def setup(hass, config):
# Log RFXCOM event # Log RFXCOM event
entity_id = slugify(event.device.id_string.lower()) entity_id = slugify(event.device.id_string.lower())
packet_id = "".join("{0:02x}".format(x) for x in event.data) packet_id = "".join("{0:02x}".format(x) for x in event.data)
entity_name = "%(entity_id)s : %(packet_id)s" % locals() entity_name = "%s : %s" % (entity_id, packet_id)
_LOGGER.info("Receive RFXCOM event from %s => %s" % (event.device, entity_name)) _LOGGER.info("Receive RFXCOM event from %s => %s",
event.device, entity_name)
# Callback to HA registered components # Callback to HA registered components
for subscriber in RECEIVED_EVT_SUBSCRIBERS: for subscriber in RECEIVED_EVT_SUBSCRIBERS:
@ -74,7 +70,8 @@ def setup(hass, config):
return True return True
def getRFXObject(packetid):
def get_rfx_object(packetid):
""" return the RFXObject with the packetid""" """ return the RFXObject with the packetid"""
try: try:
import RFXtrx as rfxtrxmod import RFXtrx as rfxtrxmod

View File

@ -46,10 +46,10 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
for entity_id, entity_info in devices.items(): for entity_id, entity_info in devices.items():
if entity_id not in rfxtrx.RFX_DEVICES: if entity_id not in rfxtrx.RFX_DEVICES:
_LOGGER.info("Add %s rfxtrx.switch", entity_info['name']) _LOGGER.info("Add %s rfxtrx.switch", entity_info['name'])
rfxobject = rfxtrx.getRFXObject(entity_info['packetid']) rfxobject = rfxtrx.get_rfx_object(entity_info['packetid'])
new_switch = RfxtrxSwitch(entity_info['name'], rfxobject, False) newswitch = RfxtrxSwitch(entity_info['name'], rfxobject, False)
rfxtrx.RFX_DEVICES[entity_id] = new_switch rfxtrx.RFX_DEVICES[entity_id] = newswitch
switchs.append(new_switch) switchs.append(newswitch)
add_devices_callback(switchs) 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: if entity_id not in rfxtrx.RFX_DEVICES:
automatic_add = config.get('automatic_add', False) automatic_add = config.get('automatic_add', False)
if automatic_add: if automatic_add:
_LOGGER.info("Automatic add %s rfxtrx.switch (class: %s subtype: %s)", _LOGGER.info(
entity_id, "Automatic add %s rfxtrx.switch (Class: %s Sub: %s)",
event.device.__class__.__name__, entity_id,
event.device.subtype event.device.__class__.__name__,
event.device.subtype
) )
packet_id = "".join("{0:02x}".format(x) for x in event.data) pkt_id = "".join("{0:02x}".format(x) for x in event.data)
entity_name = "%(entity_id)s : %(packet_id)s" % locals() entity_name = "%s : %s" % (entity_id, pkt_id)
new_switch = RfxtrxSwitch(entity_name, event, False) new_switch = RfxtrxSwitch(entity_name, event, False)
rfxtrx.RFX_DEVICES[entity_id] = new_switch rfxtrx.RFX_DEVICES[entity_id] = new_switch
add_devices_callback([new_switch]) add_devices_callback([new_switch])