Refactoring the code for pylint & flake test

This commit is contained in:
badele committed 2015-09-29 08:20:25 +02:00
1 parent 174aeacd76
commit d64f0ddd41
4 files changed
+30 -25

No files matched your search

+7 -5
View File
@@ -33,17 +33,18 @@ REQUIREMENTS = ['https://github.com/Danielhiversen/pyRFXtrx/archive/' +
'ec7a1aaddf8270db6e5da1c13d58c1547effd7cf.zip#RFXtrx==0.15']
DOMAIN = "rfxtrx"
_LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Setup the RFXtrx platform. """
logger = logging.getLogger(__name__)
# Add switch from config file
switchs = []
devices = config.get('devices')
for entity_id, entity_name in devices.items():
if entity_id not in rfxtrx.RFX_DEVICES:
logger.info("Add %s rfxtrx.switch" % entity_name)
_LOGGER.info("Add %s rfxtrx.switch", entity_name)
new_switch = RfxtrxSwitch(entity_name, False)
rfxtrx.RFX_DEVICES[entity_id] = new_switch
switchs.append(new_switch)
@@ -59,14 +60,15 @@ 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" % entity_name)
_LOGGER.info("Automatic add %s rfxtrx.switch", entity_id)
new_switch = RfxtrxSwitch(entity_id, False)
rfxtrx.RFX_DEVICES[entity_id] = new_switch
add_devices_callback([new_switch])
# Check if entity exists (previous automatic added)
if entity_id in rfxtrx.RFX_DEVICES:
if event.values['Command'] == 'On' or event.values['Command'] == 'Off':
if event.values['Command'] == 'On'\
or event.values['Command'] == 'Off':
if event.values['Command'] == 'On':
rfxtrx.RFX_DEVICES[entity_id].turn_on()
else:
@@ -105,4 +107,4 @@ class RfxtrxSwitch(SwitchDevice):
def turn_off(self, **kwargs):
""" Turn the device off. """
self._state = False
self.update_ha_state()
self.update_ha_state()