@track_state_change(light.ENTITY_ID_ALL_LIGHTS, STATE_ON, STATE_OFF)
def all_lights_off(hass, entity_id, old_state, new_state):
 if (not TARGET_ID):
  return
 if core.is_on(hass, TARGET_ID):
  _LOGGER.info('All lights have been turned off, turning it off')
  core.turn_off(hass, TARGET_ID)

@ track_state_change ( light . ENTITY_ID_ALL_LIGHTS , STATE_ON , STATE_OFF ) def all_lights_off ( hass , entity_id , old_state , new_state ) : if ( not TARGET_ID ) : return if core . is_on ( hass , TARGET_ID ) : _LOGGER . info ( 'All lights have been turned off, turning it off' ) core . turn_off ( hass , TARGET_ID )
if all lights turn off .