'Test if events are filtered if include and exclude is configured.'

def test_include_exclude_events(self):

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