def is_on(hass, entity_id=None):
 entity_id = (entity_id or ENTITY_ID)
 return hass.states.is_state(entity_id, STATE_ABOVE_HORIZON)

def is_on ( hass , entity_id = None ) : entity_id = ( entity_id or ENTITY_ID ) return hass . states . is_state ( entity_id , STATE_ABOVE_HORIZON )
test if the sun is currently up based on the statemachine .