def create_state_changed_event(self, event_time_fired, entity_id, state):
        # Logbook only cares about state change events that
        # contain an old state but will not actually act on it.
        state = ha.State(entity_id, state).as_dict()

        return ha.Event(EVENT_STATE_CHANGED, {
            'entity_id': entity_id,
            'old_state': state,
            'new_state': state,
        }, time_fired=event_time_fired)
Create state changed event.
dataset/ETHPy150Open home-assistant/home-assistant/tests/components/test_logbook.py/TestComponentHistory.create_state_changed_event