mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
MQTT Cover Fix Assumed State (#14672)
This commit is contained in:
parent
f2a2f2cca5
commit
fcb60d472e
@ -235,6 +235,11 @@ class MqttCover(MqttAvailability, CoverDevice):
|
||||
"""No polling needed."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def assumed_state(self):
|
||||
"""Return true if we do optimistic updates."""
|
||||
return self._optimistic
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the cover."""
|
||||
|
@ -2,8 +2,8 @@
|
||||
import unittest
|
||||
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.const import STATE_OPEN, STATE_CLOSED, STATE_UNKNOWN,\
|
||||
STATE_UNAVAILABLE
|
||||
from homeassistant.const import STATE_OPEN, STATE_CLOSED, STATE_UNKNOWN, \
|
||||
STATE_UNAVAILABLE, ATTR_ASSUMED_STATE
|
||||
import homeassistant.components.cover as cover
|
||||
from homeassistant.components.cover.mqtt import MqttCover
|
||||
|
||||
@ -40,6 +40,7 @@ class TestCoverMQTT(unittest.TestCase):
|
||||
|
||||
state = self.hass.states.get('cover.test')
|
||||
self.assertEqual(STATE_UNKNOWN, state.state)
|
||||
self.assertFalse(state.attributes.get(ATTR_ASSUMED_STATE))
|
||||
|
||||
fire_mqtt_message(self.hass, 'state-topic', '0')
|
||||
self.hass.block_till_done()
|
||||
@ -112,6 +113,7 @@ class TestCoverMQTT(unittest.TestCase):
|
||||
|
||||
state = self.hass.states.get('cover.test')
|
||||
self.assertEqual(STATE_UNKNOWN, state.state)
|
||||
self.assertTrue(state.attributes.get(ATTR_ASSUMED_STATE))
|
||||
|
||||
cover.open_cover(self.hass, 'cover.test')
|
||||
self.hass.block_till_done()
|
||||
|
Loading…
x
Reference in New Issue
Block a user