@track_state_change(device_tracker.ENTITY_ID_ALL_DEVICES)
def track_devices(hass, entity_id, old_state, new_state):
 if (not TARGET_ID):
  return
 if ((new_state.state == STATE_HOME) and (not core.is_on(hass, TARGET_ID))):
  core.turn_on(hass, TARGET_ID)
 elif ((new_state.state == STATE_NOT_HOME) and core.is_on(hass, TARGET_ID)):
  core.turn_off(hass, TARGET_ID)

@ track_state_change ( device_tracker . ENTITY_ID_ALL_DEVICES ) def track_devices ( hass , entity_id , old_state , new_state ) : if ( not TARGET_ID ) : return if ( ( new_state . state == STATE_HOME ) and ( not core . is_on ( hass , TARGET_ID ) ) ) : core . turn_on ( hass , TARGET_ID ) elif ( ( new_state . state == STATE_NOT_HOME ) and core . is_on ( hass , TARGET_ID ) ) : core . turn_off ( hass , TARGET_ID )
called when the group .