Cover (#2957)
* current_position was set, it should be optional * Update mqtt test to match
This commit is contained in:
parent
4795122463
commit
e5abf6074c
2 changed files with 8 additions and 6 deletions
|
@ -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:
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue