mirror of
https://github.com/home-assistant/core.git
synced 2026-09-27 18:08:37 -04:00
Logbook filtering of automations by entity_id (#3927)
* Logbook filtering of automations by entity_id * Trigger action function parameters required
This commit is contained in:
committed by
Paulus Schoutsen
parent
57f32fa629
commit
7d32e5eeeb
@@ -186,6 +186,43 @@ class TestComponentLogbook(unittest.TestCase):
|
||||
self.assert_entry(entries[1], pointB, 'blu', domain='sensor',
|
||||
entity_id=entity_id2)
|
||||
|
||||
def test_exclude_automation_events(self):
|
||||
"""Test if automation entries can be excluded by entity_id."""
|
||||
name = 'My Automation Rule'
|
||||
message = 'has been triggered'
|
||||
domain = 'automation'
|
||||
entity_id = 'automation.my_automation_rule'
|
||||
entity_id2 = 'automation.my_automation_rule_2'
|
||||
entity_id2 = 'sensor.blu'
|
||||
|
||||
eventA = ha.Event(logbook.EVENT_LOGBOOK_ENTRY, {
|
||||
logbook.ATTR_NAME: name,
|
||||
logbook.ATTR_MESSAGE: message,
|
||||
logbook.ATTR_DOMAIN: domain,
|
||||
logbook.ATTR_ENTITY_ID: entity_id,
|
||||
})
|
||||
eventB = ha.Event(logbook.EVENT_LOGBOOK_ENTRY, {
|
||||
logbook.ATTR_NAME: name,
|
||||
logbook.ATTR_MESSAGE: message,
|
||||
logbook.ATTR_DOMAIN: domain,
|
||||
logbook.ATTR_ENTITY_ID: entity_id2,
|
||||
})
|
||||
|
||||
config = logbook.CONFIG_SCHEMA({
|
||||
ha.DOMAIN: {},
|
||||
logbook.DOMAIN: {logbook.CONF_EXCLUDE: {
|
||||
logbook.CONF_ENTITIES: [entity_id, ]}}})
|
||||
events = logbook._exclude_events((ha.Event(EVENT_HOMEASSISTANT_STOP),
|
||||
eventA, eventB), config)
|
||||
entries = list(logbook.humanify(events))
|
||||
|
||||
self.assertEqual(2, len(entries))
|
||||
self.assert_entry(
|
||||
entries[0], name='Home Assistant', message='stopped',
|
||||
domain=ha.DOMAIN)
|
||||
self.assert_entry(
|
||||
entries[1], name=name, domain=domain, entity_id=entity_id2)
|
||||
|
||||
def test_include_events_entity(self):
|
||||
"""Test if events are filtered if entity is included in config."""
|
||||
entity_id = 'sensor.bla'
|
||||
|
||||
Reference in New Issue
Block a user