home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.34k stars 29.88k forks source link

device_tracker is set to 'not_home' shortly after every restart #18930

Closed steve28 closed 5 years ago

steve28 commented 5 years ago

Home Assistant release with the issue:

0.83.2

Last working Home Assistant release (if known):

0.82.x (latest in the 0.82 series)

Operating environment (Hass.io/Docker/Windows/etc.):

Docker on Ubuntu 18.04

Component/platform:

device_tracker, maybe recorer https://www.home-assistant.io/components/device_tracker/ https://www.home-assistant.io/components/recorder/

Description of problem:

Upon restart of Home Assistant, my iOS device gets marked as not_home. This occurs every restart since updating to 0.83.x. I have deleted the database file thinking that it could have been corrupted, but that did not help. As you can see from the log below, it starts out with an old state of None, then gets updated to home then 7 seconds later, it updates to not_home. This is 100% reproducible for me.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

# track phones
device_tracker:

# iOS Support
ios:
  push:
    categories:
      - name: Garage Door Open
        identifier: 'garagedoor'
        actions:
          - identifier: 'CLOSE_GARAGE_DOOR'
            title: 'Close Door'
            activationMode: 'background'

Traceback (if applicable):

Additional information:

Here is a log of what happens on restart (filtered to show entries related to my phone steves_iphone_x:


$ cat home-assistant.log | grep steves_iphone_x
2018-12-02 09:31:33 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=group.family, old_state=None, new_state=<state group.family=unknown; entity_id=('device_tracker.steves_iphone_x', 'device_tracker.airies_iphone_se'), order=0, friendly_name=Family @ 2018-12-02T09:31:33.047991-08:00>>
2018-12-02 09:31:33 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=group, service=set, service_data=object_id=all_devices, visible=False, name=all devices, entities=['device_tracker.steves_iphone_x', 'device_tracker.airies_iphone_se'], service_call_id=86b51bd45414423f9c5769fb3e3d7450>
2018-12-02 09:31:33 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=group.all_devices, old_state=None, new_state=<state group.all_devices=unknown; entity_id=('device_tracker.steves_iphone_x', 'device_tracker.airies_iphone_se'), order=2, auto=True, friendly_name=all devices, hidden=True @ 2018-12-02T09:31:33.485624-08:00>>
2018-12-02 09:31:33 DEBUG (SyncWorker_0) [homeassistant.helpers.restore_state] Created cache with ['automation.apartment_alarms', 'automation.arrive_actions', 'automation.attic_lights_autooff', 'automation.attic_lights_autoon', 'automation.automation_debug_switch', 'automation.away_actions', 'automation.close_the_garage_door', 'automation.device_tracter_debug_switch', 'automation.dog_lights', 'automation.door_alarm_when_away', 'automation.fence_lights', 'automation.garage_door_warning_left', 'automation.garage_door_warning_right', 'automation.garage_welcome_lights', 'automation.gentle_wake', 'automation.ha_update_homekit', 'automation.homekit_update_ha', 'automation.house_welcome_lights', 'automation.landscape_lights', 'automation.left_auto_open', 'automation.left_auto_open_detect', 'automation.motion_alarm_when_away', 'automation.mqtt_debug_switch', 'automation.python_scripts_debug_switch', 'automation.right_auto_open', 'automation.right_auto_open_detect', 'automation.scenes_for_homekit', 'automation.start_homekit', 'automation.ups_status_change_notification', 'automation.vacation_lights', 'automation.zigbee_debug_switch', 'binary_sensor.apartment_door', 'binary_sensor.apartment_motion', 'binary_sensor.attic_door', 'binary_sensor.back_door', 'binary_sensor.bedroom_motion', 'binary_sensor.bedroom_outside_door', 'binary_sensor.family_room_motion', 'binary_sensor.family_room_thermostat_online', 'binary_sensor.front_door', 'binary_sensor.garage_side_door', 'binary_sensor.guest_motion', 'binary_sensor.home_away', 'binary_sensor.kitchen_door', 'binary_sensor.kitchen_motion', 'binary_sensor.living_room_motion', 'binary_sensor.office_motion', 'binary_sensor.ring_front_door_ding', 'binary_sensor.ring_front_door_motion', 'calendar.jpl_rdo', 'calendar.steve_vacay', 'camera.front_door', 'camera.front_door_2', 'climate.family_room', 'cover.left_garage_door', 'cover.right_garage_door', 'device_tracker.airies_iphone_se', 'device_tracker.steves_iphone_x', 'group.family', 'input_boolean.airie_homekit', 'input_boolean.automation_debug', 'input_boolean.bedtime', 'input_boolean.device_tracker_debug', 'input_boolean.gina_bedtime', 'input_boolean.home_audio_master_power', 'input_boolean.home_audio_zone_1', 'input_boolean.home_audio_zone_2', 'input_boolean.home_audio_zone_3', 'input_boolean.home_audio_zone_4', 'input_boolean.home_audio_zone_5', 'input_boolean.home_audio_zone_6', 'input_boolean.left_garage_auto_open', 'input_boolean.mqtt_debug', 'input_boolean.python_script_debug', 'input_boolean.right_garage_auto_open', 'input_boolean.steve_homekit', 'input_boolean.tv_time', 'input_boolean.vacation_mode', 'input_boolean.zigbee_debug', 'input_number.slider1', 'input_number.slider2', 'input_number.slider3', 'input_number.slider4', 'input_number.slider5', 'input_number.slider6', 'light.attic_light', 'light.bedroom_lights', 'light.family_room_lights', 'light.living_room_lights', 'light.siren_level', 'media_player.airies_alexa_apps', 'media_player.apple_tv', 'media_player.apple_tv_2', 'media_player.bedroom', 'media_player.everywhere', 'media_player.family_room_roku', 'media_player.family_room_tv', 'media_player.kitchen', 'media_player.living_room', 'media_player.office', 'media_player.steves_alexa_apps', 'media_player.steves_fire', 'media_player.this_device', 'persistent_notification.config_entry_discovery', 'remote.apple_tv', 'remote.apple_tv_2', 'remote.bedroom_hub', 'remote.living_room', 'script.timed_lights', 'sensor.apartment_temperature', 'sensor.bedroom_smoke_alarm', 'sensor.bedroom_smoke_alarm_battery', 'sensor.dark_sky_humidity', 'sensor.dark_sky_icon', 'sensor.dark_sky_summary', 'sensor.dark_sky_temperature', 'sensor.family_room_thermostat_humidity', 'sensor.family_room_thermostat_hvac_state', 'sensor.garage_humidity', 'sensor.garage_temperature', 'sensor.guest_room_motion_sensor_temperature', 'sensor.home_eta', 'sensor.homeassistant_v2db', 'sensor.house_power', 'sensor.kitchen_motion_sensor_temperature', 'sensor.laundry_laundry_smoke_co_alarm_battery', 'sensor.laundry_smoke_co_alarm', 'sensor.office_motion_sensor_temperature', 'sensor.router_cert_expires', 'sensor.server_cert_expires', 'sensor.ups_battery', 'sensor.ups_input_voltage', 'sensor.ups_load', 'sensor.ups_status', 'sensor.ups_time_left', 'sensor.ups_time_on_battery', 'sensor.ups_total_time_on_battery', 'sensor.ups_transfer_count', 'switch.attic_stairs_light', 'switch.back_door_light', 'switch.backyard_flood_lights', 'switch.bathroom_fan', 'switch.bathroom_vanity', 'switch.bedroom_fan', 'switch.bedroom_tv', 'switch.desk_lamp_switch', 'switch.dining_room_light', 'switch.family_room_fan', 'switch.family_room_tv', 'switch.fence_lights', 'switch.front_door_lights', 'switch.garage_outside_light', 'switch.ginas_bathroom_light', 'switch.ginas_room_light', 'switch.guest_bathroom_light_switch', 'switch.home_audio_system', 'switch.kitchen_door_inside_light', 'switch.kitchen_door_outside_light', 'switch.kitchen_lights', 'switch.landscape_lighting', 'switch.laundry_light', 'switch.left_garage_auto_open', 'switch.living_room_tv', 'switch.mini', 'switch.office_light_switch', 'switch.outlet_plug_switch', 'switch.patio_lights', 'switch.right_garage_auto_open', 'switch.upstairs_room_light', 'switch.utility_room_light']
2018-12-02 09:31:33 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=device_tracker.steves_iphone_x, old_state=None, new_state=<state device_tracker.steves_iphone_x=home; source_type=gps, latitude=34.14847841448536, longitude=-118.39398372367906, gps_accuracy=65, battery=100, friendly_name=Steve @ 2018-12-02T09:31:33.789052-08:00>>
2018-12-02 09:31:33 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=group.family, old_state=<state group.family=unknown; entity_id=('device_tracker.steves_iphone_x', 'device_tracker.airies_iphone_se'), order=0, friendly_name=Family @ 2018-12-02T09:31:33.047991-08:00>, new_state=<state group.family=home; entity_id=('device_tracker.steves_iphone_x', 'device_tracker.airies_iphone_se'), order=0, friendly_name=Family @ 2018-12-02T09:31:33.795835-08:00>>
2018-12-02 09:31:33 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=group.all_devices, old_state=<state group.all_devices=unknown; entity_id=('device_tracker.steves_iphone_x', 'device_tracker.airies_iphone_se'), order=2, auto=True, friendly_name=all devices, hidden=True @ 2018-12-02T09:31:33.485624-08:00>, new_state=<state group.all_devices=home; entity_id=('device_tracker.steves_iphone_x', 'device_tracker.airies_iphone_se'), order=2, auto=True, friendly_name=all devices, hidden=True @ 2018-12-02T09:31:33.796762-08:00>>
2018-12-02 09:31:33 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.steves_iphone_x_battery_level, old_state=None, new_state=<state sensor.steves_iphone_x_battery_level=100; Battery State=Unplugged, Battery Level=100, Device Type=iPhone11,2, Device Name=Steve's iPhone X, Device Version=12.1, unit_of_measurement=%, friendly_name=Steve's iPhone X Battery Level, icon=mdi:battery, hidden=True @ 2018-12-02T09:31:33.839176-08:00>>
2018-12-02 09:31:33 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=notify, service=ios_steves_iphone_x>
2018-12-02 09:31:33 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.steves_iphone_x_battery_state, old_state=None, new_state=<state sensor.steves_iphone_x_battery_state=Unplugged; Battery State=Unplugged, Battery Level=100, Device Type=iPhone11,2, Device Name=Steve's iPhone X, Device Version=12.1, friendly_name=Steve's iPhone X Battery State, icon=mdi:power-plug-off, hidden=True @ 2018-12-02T09:31:33.848802-08:00>>
2018-12-02 09:31:40 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=device_tracker.steves_iphone_x, old_state=<state device_tracker.steves_iphone_x=home; source_type=gps, latitude=34.14847841448536, longitude=-118.39398372367906, gps_accuracy=65, battery=100, friendly_name=Steve @ 2018-12-02T09:31:33.789052-08:00>, new_state=<state device_tracker.steves_iphone_x=not_home; source_type=gps, battery=100, friendly_name=Steve @ 2018-12-02T09:31:40.001793-08:00>>
2018-12-02 09:31:40 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=group.family, old_state=<state group.family=home; entity_id=('device_tracker.steves_iphone_x', 'device_tracker.airies_iphone_se'), order=0, friendly_name=Family @ 2018-12-02T09:31:33.795835-08:00>, new_state=<state group.family=not_home; entity_id=('device_tracker.steves_iphone_x', 'device_tracker.airies_iphone_se'), order=0, friendly_name=Family @ 2018-12-02T09:31:40.003910-08:00>>
2018-12-02 09:31:40 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=group.all_devices, old_state=<state group.all_devices=home; entity_id=('device_tracker.steves_iphone_x', 'device_tracker.airies_iphone_se'), order=2, auto=True, friendly_name=all devices, hidden=True @ 2018-12-02T09:31:33.796762-08:00>, new_state=<state group.all_devices=not_home; entity_id=('device_tracker.steves_iphone_x', 'device_tracker.airies_iphone_se'), order=2, auto=True, friendly_name=all devices, hidden=True @ 2018-12-02T09:31:40.005223-08:00>>
2018-12-02 09:31:40 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=device_tracker, service=see, service_data=dev_id=steves_iphone_x, location_name=not_home, service_call_id=d0da3a250f2a4de7958866c411db2d0d>
2018-12-02 09:31:40 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=notify, service=ios_steves_iphone_x, service_data=message=steve garage set, service_call_id=8cbe039df4824106a27cb7cfb2bf1def>
2018-12-02 09:31:40 INFO (SyncWorker_13) [homeassistant.components.notify.ios] iOS push notification rate limits for steves_iphone_x: 21 sent, 150 allowed, 0 errors, resets in 6:28:19```
heyitsyang commented 5 years ago

This may be related - though I do not have the state restoration problem. I have been experiencing anomalous device tracker behavior as well since updating to 83.2. I have been using Owntracks (+ BT beacons) and Ping also on Ubuntu (Python virtual env, no Docker). If both Owntracks and Ping report I am not_home then I am not. If either Owntracks or Ping report I am home my status is home. The arrangement has worked reliably for me for over a year.

Since updating to 83.2, my Owntracks status bounces from home to not_home quite a bit more when my actual location is unchanged. The only change in my yaml is my moving owntracks configuration from under "device_tracker:" to "owntracks:". (Without this configuration change, ver 83.2 will not start but does not generate an error.) Ping also seems less "solid".

I've also tried duplicating some of the device tracker options (consider_home, interval_seconds, etc.) under "owntracks:" since I didn't know if owntracks would pick them up anymore in the new configuration, but no luck.

mgiako commented 5 years ago

Same issue here, I downgraded to 0.82.1 because owntracks is unusable. But ios app tracker has the same issue. Maybe there's some relationship

erfind commented 5 years ago

This same issue happens with the Geofency plugin as well and has been for a while.

arsaboo commented 5 years ago

Yes, this has been reported and currently being investigated. Many states are not being restored. Hopefully, it will be fixed in the next release.

HACee commented 5 years ago

Having the same problem on a MQTT Device tracker I have setup though Monitor script on a Pi Zero.

towerhand commented 5 years ago

Related to #18662

bachya commented 5 years ago

Cross-post from Discord user phnx:

the entire state machine is getting overhauled in 0.84 should probably ask some of these folks to test the beta

If anyone can give the beta a shot and confirm, that would be helpful.

steve28 commented 5 years ago

I just installed 0.84.0b1 and it still occurs. All device_tracker entities are set to not_home on restart.

arsaboo commented 5 years ago

This issue is fixed and can be closed now.