'Test if automation entries can be excluded by entity_id.'

def test_exclude_automation_events(self):

    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[logbook.DOMAIN])
    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)
