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():
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])

View File

@ -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

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():
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])