1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Bugfix trigger state with multible entities (#10857)

* Bugfix trigger state with multible entities

* Fix numeric state

* fix lint

* fix dict

* fix unsub

* fix logic

* fix name

* fix new logic

* add test for state

* add numeric state test for unsub

* add test for multible entities

* Update numeric_state.py

* Update numeric_state.py

* Update state.py

* Fix logic for triple match

* Add clear to numeric state

* clear for state trigger
This commit is contained in:
Pascal Vizeli
2017-11-30 21:03:52 +01:00
committed by GitHub
parent bfc61c268a
commit ea6ca9252c
4 changed files with 134 additions and 16 deletions

View File

@@ -334,6 +334,47 @@ class TestAutomationState(unittest.TestCase):
self.hass.block_till_done()
self.assertEqual(0, len(self.calls))
def test_if_not_fires_on_entities_change_with_for_after_stop(self):
"""Test for not firing on entity change with for after stop trigger."""
assert setup_component(self.hass, automation.DOMAIN, {
automation.DOMAIN: {
'trigger': {
'platform': 'state',
'entity_id': [
'test.entity_1',
'test.entity_2',
],
'to': 'world',
'for': {
'seconds': 5
},
},
'action': {
'service': 'test.automation'
}
}
})
self.hass.states.set('test.entity_1', 'world')
self.hass.states.set('test.entity_2', 'world')
self.hass.block_till_done()
fire_time_changed(self.hass, dt_util.utcnow() + timedelta(seconds=10))
self.hass.block_till_done()
self.assertEqual(2, len(self.calls))
self.hass.states.set('test.entity_1', 'world_no')
self.hass.states.set('test.entity_2', 'world_no')
self.hass.block_till_done()
self.hass.states.set('test.entity_1', 'world')
self.hass.states.set('test.entity_2', 'world')
self.hass.block_till_done()
automation.turn_off(self.hass)
self.hass.block_till_done()
fire_time_changed(self.hass, dt_util.utcnow() + timedelta(seconds=10))
self.hass.block_till_done()
self.assertEqual(2, len(self.calls))
def test_if_fires_on_entity_change_with_for_attribute_change(self):
"""Test for firing on entity change with for and attribute change."""
assert setup_component(self.hass, automation.DOMAIN, {