

def mock_state_change_event(hass, new_state, old_state=None):
    'Mock state change envent.'
    event_data = {
        'entity_id': new_state.entity_id,
        'new_state': new_state,
    }
    if new_state:
        event_data['old_state'] = old_state
    hass.bus.fire(EVENT_STATE_CHANGED, event_data)

dataset/ETHPy150Open home-assistant/home-assistant/tests/common.py mock_state_change_event/VarMisuse@37/69 `old_state`->`new_state`