Automation: Add trigger context and expose to action
This commit is contained in:
1 parent
c4913a87e4
commit
4e568f8b99
20 files changed
+232
-69
No files matched your search
@@ -31,6 +31,9 @@ class TestAutomationState(unittest.TestCase):
|
||||
|
||||
def test_if_fires_on_entity_change(self):
|
||||
"""Test for firing on entity change."""
|
||||
self.hass.states.set('test.entity', 'hello')
|
||||
self.hass.pool.block_till_done()
|
||||
|
||||
assert _setup_component(self.hass, automation.DOMAIN, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
@@ -38,7 +41,13 @@ class TestAutomationState(unittest.TestCase):
|
||||
'entity_id': 'test.entity',
|
||||
},
|
||||
'action': {
|
||||
'service': 'test.automation'
|
||||
'service': 'test.automation',
|
||||
'data_template': {
|
||||
'some': '{{ trigger.%s }}' % '}} - {{ trigger.'.join((
|
||||
'platform', 'entity_id',
|
||||
'from_state.state', 'to_state.state',
|
||||
'for'))
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -46,6 +55,9 @@ class TestAutomationState(unittest.TestCase):
|
||||
self.hass.states.set('test.entity', 'world')
|
||||
self.hass.pool.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
self.assertEqual(
|
||||
'state - test.entity - hello - world - None',
|
||||
self.calls[0].data['some'])
|
||||
|
||||
def test_if_fires_on_entity_change_with_from_filter(self):
|
||||
"""Test for firing on entity change with filter."""
|
||||
|
||||
Reference in new issue
Block a user