def is_on(hass, entity_id=None):
    entity_id = entity_id or ENTITY_ID_ALL_SWITCHES
    return hass.states.is_state(entity_id, STATE_ON)
Return if the switch is on based on the statemachine.
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/components/switch/__init__.py/is_on