Fix bug related to maker_param types

This commit is contained in:
pavoni 2016-01-20 19:13:29 +00:00
parent 0de9229d75
commit 7ad5b3a17b

View File

@ -97,19 +97,18 @@ class WemoSwitch(SwitchDevice):
@property @property
def state_attributes(self): def state_attributes(self):
attr = super().state_attributes or {} attr = super().state_attributes or {}
if self.maker_params: if self.maker_params:
# Is the maker sensor on or off. # Is the maker sensor on or off.
if self.entity_id == 'switch.hi_fi_systemline_sensor':
if self.maker_params['hassensor']: if self.maker_params['hassensor']:
# Note a state of 1 matches the WeMo app 'not triggered'! # Note a state of 1 matches the WeMo app 'not triggered'!
if self.maker_params['sensorstate'] == '1': if self.maker_params['sensorstate']:
attr[ATTR_SENSOR_STATE] = STATE_OFF attr[ATTR_SENSOR_STATE] = STATE_OFF
else: else:
attr[ATTR_SENSOR_STATE] = STATE_ON attr[ATTR_SENSOR_STATE] = STATE_ON
# Is the maker switch configured as toggle(0) or momentary (1). # Is the maker switch configured as toggle(0) or momentary (1).
if self.maker_params['switchmode']: if self.maker_params['switchmode']:
if self.maker_params['switchmode'] == '1':
attr[ATTR_SWITCH_MODE] = MAKER_SWITCH_MOMENTARY attr[ATTR_SWITCH_MODE] = MAKER_SWITCH_MOMENTARY
else: else:
attr[ATTR_SWITCH_MODE] = MAKER_SWITCH_TOGGLE attr[ATTR_SWITCH_MODE] = MAKER_SWITCH_TOGGLE