'Test if events are filtered if domain is excluded in config.'

def test_exclude_events_domain(self):

    entity_id = 'switch.bla'
    entity_id2 = 'sensor.blu'
    pointA = dt_util.utcnow()
    pointB = (pointA + timedelta(minutes=logbook.GROUP_BY_MINUTES))
    eventA = self.create_state_changed_event(pointA, entity_id, 10)
    eventB = self.create_state_changed_event(pointB, entity_id2, 20)
    config = logbook.CONFIG_SCHEMA({ha.DOMAIN: {}, logbook.DOMAIN: {logbook.CONF_EXCLUDE: {logbook.CONF_DOMAINS: ['switch']}}})
    events = logbook._exclude_events((ha.Event(EVENT_HOMEASSISTANT_START), eventA, eventB), config[logbook.DOMAIN])
    entries = list(logbook.humanify(events))
    self.assertEqual(2, len(entries))
    self.assert_entry(entries[0], name='Home    Assistant', message='started', domain=ha.DOMAIN)
    self.assert_entry(entries[1], pointB, 'blu', domain='sensor', entity_id=entity_id2)
