* current_position was set, it should be optional

* Update mqtt test to match
This commit is contained in:
John Arild Berentsen 2016-08-24 11:53:02 +02:00 committed by GitHub
parent 4795122463
commit e5abf6074c
2 changed files with 8 additions and 6 deletions

View File

@ -163,7 +163,7 @@ class CoverDevice(Entity):
None is unknown, 0 is closed, 100 is fully open. None is unknown, 0 is closed, 100 is fully open.
""" """
return None pass
@property @property
def current_cover_tilt_position(self): def current_cover_tilt_position(self):
@ -171,7 +171,7 @@ class CoverDevice(Entity):
None is unknown, 0 is closed, 100 is fully open. None is unknown, 0 is closed, 100 is fully open.
""" """
return None pass
@property @property
def state(self): def state(self):
@ -186,9 +186,11 @@ class CoverDevice(Entity):
@property @property
def state_attributes(self): def state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
data = { data = {}
ATTR_CURRENT_POSITION: self.current_cover_position
} current = self.current_cover_position
if current is not None:
data[ATTR_CURRENT_POSITION] = self.current_cover_position
current_tilt = self.current_cover_tilt_position current_tilt = self.current_cover_tilt_position
if current_tilt is not None: if current_tilt is not None:

View File

@ -147,7 +147,7 @@ class TestCoverMQTT(unittest.TestCase):
state_attributes_dict = self.hass.states.get( state_attributes_dict = self.hass.states.get(
'cover.test').attributes 'cover.test').attributes
self.assertTrue('current_position' in state_attributes_dict) self.assertFalse('current_position' in state_attributes_dict)
fire_mqtt_message(self.hass, 'state-topic', '0') fire_mqtt_message(self.hass, 'state-topic', '0')
self.hass.pool.block_till_done() self.hass.pool.block_till_done()