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

View file

@ -147,7 +147,7 @@ class TestCoverMQTT(unittest.TestCase):
state_attributes_dict = self.hass.states.get(
'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')
self.hass.pool.block_till_done()