Add missing availability schema to MQTT alarm panel (#11829)
* Add missing availability schema to MQTT alarm panel * Add tests for default MQTT availability payloads
This commit is contained in:
1 parent
a470cc212e
commit
2cfbd0dc1d
10 files changed
+274
-11
No files matched your search
@@ -465,6 +465,34 @@ class TestLightMQTTTemplate(unittest.TestCase):
|
||||
state = self.hass.states.get('light.test')
|
||||
self.assertEqual('rainbow', state.attributes.get('effect'))
|
||||
|
||||
def test_default_availability_payload(self):
|
||||
"""Test availability by default payload with defined topic."""
|
||||
self.assertTrue(setup_component(self.hass, light.DOMAIN, {
|
||||
light.DOMAIN: {
|
||||
'platform': 'mqtt_template',
|
||||
'name': 'test',
|
||||
'command_topic': 'test_light_rgb/set',
|
||||
'command_on_template': 'on,{{ transition }}',
|
||||
'command_off_template': 'off,{{ transition|d }}',
|
||||
'availability_topic': 'availability-topic'
|
||||
}
|
||||
}))
|
||||
|
||||
state = self.hass.states.get('light.test')
|
||||
self.assertEqual(STATE_UNAVAILABLE, state.state)
|
||||
|
||||
fire_mqtt_message(self.hass, 'availability-topic', 'online')
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get('light.test')
|
||||
self.assertNotEqual(STATE_UNAVAILABLE, state.state)
|
||||
|
||||
fire_mqtt_message(self.hass, 'availability-topic', 'offline')
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get('light.test')
|
||||
self.assertEqual(STATE_UNAVAILABLE, state.state)
|
||||
|
||||
def test_custom_availability_payload(self):
|
||||
"""Test availability by custom payload with defined topic."""
|
||||
self.assertTrue(setup_component(self.hass, light.DOMAIN, {
|
||||
|
||||
Reference in new issue
Block a user