Device Tracking with HA App

Hi,

I’m running Hassio on a RBPi3. I had device tracking working with iCloud but removed this due to battery drain on both tracked phones.
Now I’m struggling to get tracking to work with the HA IOS App outside of my house.

In house both devices show as ‘home’ based on NMAP;

device_tracker:

  - platform: nmap_tracker
    hosts: 
      - 192.168.1.225
      - 192.168.1.227
      - 192.168.1.216
    home_interval: 10

But outside my home I can’t get it to work with the HA IOS app (v 0.102.3)

I’ve added this to my configuration.yaml;

ios: !include ios.yaml

and have a separate ios.yaml with;

ios: 

But the devices both do not report the zone when I move to for example my 'work zone, they goto status: ‘Away’ instead. (The zones worked fine with iCloud tracking, have not changed anything on these.)
Both devices show in ‘known_devices’, but from what I’ve read this isn’t used anymore (?)

I see both devices in the dev tools as:

device_tracker.yellowghost

source_type: router
scanner: NmapDeviceScanner
ip: 192.168.1.227
friendly_name: Martijn
entity_picture: /local/martijn.jpg

The HA IOS App doesn’t seem to make any trackable entities…
What am I missing or doing wrong?

Add

mobile_app:

To your configuration.yaml. This should create a device tracker and some other sensors for each device.

When I add that I get this in my startup log;

**homeassistant.exceptions.HomeAssistantError: Entity id already exists: device_tracker.yellowghost. Platform mobile_app does not generate unique IDs**
**2019-12-09 10:16:23 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved**
**Traceback (most recent call last):**
**  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 399, in _async_add_entity**
**    raise HomeAssistantError(msg)**
**homeassistant.exceptions.HomeAssistantError: Entity id already exists: device_tracker.rineke. Platform mobile_app does not generate unique IDs**
**2019-12-09 10:16:23 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved**

The entity ID’s it tries to make already seem to exist from the NMAP scanner, how do I get it to create unique ID’s or how do I change the existing ID’s?

You can change the entity_id of the device tracker by going to the Sidebar->Configuration -> Entities.
Click on the entity, change the name to something like device_tracker.yellowghost_nmap and hit update. Then restart and check if it worked.

Hello… Nmap_tracker is only (I think) for tracking devices on a local area network (LAN) so there is two states available as far as I know: “home” or “not_home”… How HA can locate your device with nmap if you are not connected to the LAN anymore ? If you want to locate the device outside of your home, you need to use an application like OwnTracks which is giving your GPS position to HA . Associated with “zone” definitions, this can give you as many state as you want: “home”, “not_home”, “work”, “school”, etc…

I know NMAP is for local scanning only, I’d like to use the HA IOS App for tracking outside of my house. I’ve already setup the zones (work, school, home, etc) and these worked fine with icloud tracking.
I’m just having a hard time setting up the tracking with the IOS app.

OK… I misunderstood the question. As I am not using this IOS app, I can not help on this… I am using OwnTracks app for tracking where is my phone when away from home.

Did you try changing the entity_id as I suggested?

I’m really lost here…

I restarted HA and then tried changing the entity_id like you said, but I dont see the NMAP device trackers.
All I see in Configuration > Entities is: “device_tracker.yellowghost” which comes from the Mobile App integration.

Logs still say;

2019-12-09 11:52:15 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 399, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: device_tracker.yellowghost. Platform mobile_app does not generate unique IDs

Setting ‘device_tracker.yellowghost’ as the entity in a badge, only gives status ‘Away’ while I’m in my ‘work’ zone at the moment. When I click the badge for more details it shows the ‘source type’ as ‘-’

What happens if you delete the two device trackers and restart the system?

After removing ‘device_tracker.yellowghost’ I see this after a restart;

But both _2 and _3 give status unknown.

Hmm that’s strange. Can you comment out mobile_app:, restart, delete the entities, restart, uncomment mobile_app: and restart again? Maybe also comment out the nmap device_tracker and add it again later.

Done:

  • Commented out mobile_app and the nmap tracker.
  • Restart
  • Removed entities (device_tracker.yellowghost_2 & _3)
  • Restart
  • Uncommented mobile_app
  • Restart

Result:

I dont get why it’s still called ‘device_tracker.yellowghost_2’ as there are no other trackers with the same name anymore.
Adding this tracker to a badge gives status ‘Home’ (Source type: GPS), but I’m not home at the moment, instead the location should be ‘Work’.

I think it takes some time until the state updates.

your “ios” include is wrong. You are declaring ios twice, so it won’t work.

in configuration you literally need ONLY ios: for it to work. Don’t reference another file with the same thing in it. The way you are calling it now is like:

ios:
  ios:
1 Like

Ok after resetting the app on my phone, and after removing an entry from ‘known_devices.yaml’ and I got my phone to register as en entity named: ‘device_tracker.yellowghost’ via the Mobile App.

known_devices.yaml had this:

yellowghost:
  hide_if_away: false
  icon:
  mac: <macaddress>
  name: Martijn
  picture: /local/martijn.jpg
  track: true

I think this was causing the double entity.id’s

However, the state of device_tracker.yellowghost is still not updating, not even when opening the app (while not running, this should update the location)

gps

gps2

@flamingm0e: Are you sure? I had this working with iCloud tracking.
I thought having ‘ios: !include ios.yaml’ only points to the ios.yaml file. And the actual config for ios should be done in there? So in my case I only had: ‘ios:’ in ios.yaml
Either way, for testing i’ve removed ‘!include ios.yaml’ and simply added: ‘ios:’ to my configuration.yaml. Unfortunately nothing changed.

Ok, silly question. But your Home Assistant setup is accessible remotely right? Because that is needed for the app to send info to it.
So you need a public web url for your Home Assistant.

Well, it’s just like any other !include, and if you include double, it won’t work properly, unless it is designed to IGNORE the !include, in which case it wouldn’t matter, but why would you do an include on a component that doesn’t require any configuration?

Don’t know when the device tracker should update. I’d monitor this for a few hours and see if it changes.

Yep, remote access is enabled.

Asking the real questions here! To be honest, no idea, doesn’t make sense now that you point it out. A rookie mistake I suppose. Fixed it by deleting the ios.yaml and just added ios: to configuration.yaml :grin:

Unfortunately its still not working…

I’ve reset the IOS app and before reconnecting Ive removed all Mobile App integrations in Ha. Then I connected the app to HA again.
In HA I now see 1 entity called device_tracker.yellowghost. When I use that entity for a badge and click on it I see this:

However, location is not updated, I’ve had this configured for a few hours now and moved between few zones during that time. Location is still set to ‘home’.

I’ve cleared my known_devices.yaml, since having anything there causes the source type on the image to change to ‘-’ instead of gps.
my known_devices. yaml looked like this;

yellowghost:
  hide_if_away: false
  icon:
  mac: <MAC ADDRESS>
  name: Martijn
  picture: /local/martijn.jpg
  track: true

I’ve still have the nmap tracker commented out in my configuration.yaml.
Other than that I have all other requirements I think… What am I still missing?

Here’s my configuration.yaml

homeassistant:
  name: Home
  latitude: xxx
  longitude: xxx
  elevation: -2
  unit_system: metric
  time_zone: Europe/Amsterdam

config:
updater:
default_config:


### DNS SETUP ###
# Duck Dns
http:
  base_url: xxx
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem

### BAD NEST

badnest:
  issue_token: "XXX"
  cookie: "XXX"


weather:
  - platform: darksky
    api_key: xxx
    mode: daily


mqtt:
  broker: core-mosquitto
  username: xxx
  password: !secret mqtt_password


hacs:
  token: XXX


cloud:


cast:
  view: "status"  
    

tts:
  - platform: google_translate
    cache: true
    cache_dir: /tmp/tts
    time_memory: 300
    service_name: google_say


# Includes Frontend (Themes)
frontend: !include frontend.yaml

# Includes Automations
automation: !include automations.yaml  

# Includes Cameras
camera: !include camera.yaml

# Enables ios 
ios:

# Enables tplink
tplink: 

#Enables Streaming
stream:

#Enables Map on sidebar 
map:


### Device Trackers ###

#Enables Mobile App tracking
mobile_app:

# device_tracker:

#  - platform: nmap_tracker
#    hosts: 
#     - 192.168.1.225
#     - 192.168.1.227
#     - 192.168.1.216
#    home_interval: 10

### ZONES ###

# Zones shown on map
zone:
  - name: Work
    latitude: xxx
    longitude: xxx
    radius: 100
    icon: mdi:office-building

  - name: Work2
    latitude: xxx
    longitude: xxx
    radius: 100
    icon: mdi:office-building
    
  - name: Daycare
    latitude: xxx
    longitude: xxx
    radius: 100
    icon: mdi:emoticon-poop
    
  - name: Home
    latitude: xxx
    longitude: xxx
    radius: 100
    icon: mdi:home-outline
    
  - name: Dad
    latitude: xxx
    longitude: xxx
    radius: 100
    icon: mdi:home-city-outline
    
  - name: Dad2
    latitude: xxx
    longitude: xxx
    radius: 100
    icon: mdi:home-city-outline
    
  - name: Grandma
    latitude: xxx
    longitude: xxx
    radius: 100
    icon: mdi:home-city-outline
    
    

### SENSORS ###

sensor:

  - platform: template
    sensors:
      woonkamer_temperatuur:
        friendly_name: "Woonkamer Temperatuur"
        entity_id: climate.woonkamer_thermostat
        unit_of_measurement: '°C'
        value_template: "{{ state_attr('climate.woonkamer_thermostat', 'current_temperature') }}"

  # Sensors Batterij Status
  - platform: template
    sensors:
      zoldertrap_motion_battery:
        friendly_name: 'Zoldertrap Motion Batterij'
        value_template: '{{ state_attr("binary_sensor.wyzesense_777feee1","battery_level") }}'
        unit_of_measurement: '%'

  - platform: template
    sensors:
      frontdoor_sensor_battery:
        friendly_name: 'Voordeur Sensor Batterij'
        value_template: '{{ state_attr("binary_sensor.wyzesense_7784c7dc","battery_level") }}'
        unit_of_measurement: '%'
        
  - platform: template
    sensors:
      backdoor_sensor_battery:
        friendly_name: 'Achterdeur Sensor Batterij'
        value_template: '{{ state_attr("binary_sensor.wyzesense_7784c80b","battery_level") }}'
        unit_of_measurement: '%'
        
  - platform: template
    sensors:
      toilet_motion_battery:
        friendly_name: 'Toilet Sensor Batterij'
        value_template: '{{ state_attr("binary_sensor.hue_motion_sensor_1_motion","battery_level") }}'
        unit_of_measurement: '%'



  # RbPi Systeem monitor
  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /
      - type: memory_free
      - type: processor_use
      - type: memory_use_percent
      - type: ipv4_address
        arg: eth0
        

  # Garbage Collection
  - platform: garbage_collection
    name: "Plastic" # Bi-weekly (odd weeks) on Friday. Between January and December
    frequency: "odd-weeks"
    first_month: "jan"
    last_month: "dec"
    collection_days: "fri"
    verbose_state: true
    
  - platform: garbage_collection
    name: "Papier" # Bi-weekly (even weeks) on Thursday. Between January and December
    frequency: "even-weeks"
    first_month: "jan"
    last_month: "dec"
    collection_days: "thu"
    verbose_state: true
    
  - platform: garbage_collection
    name: "Rest" # Bi-weekly (odd weeks) on Friday. Between January and December
    frequency: "even-weeks"
    first_month: "jan"
    last_month: "dec"
    collection_days: "fri"
    verbose_state: true
    
  - platform: garbage_collection
    name: "Waste not on Holidays" # No collection on Christmas
    frequency: "weekly"
    collection_days:
    - wed
    exclude_dates:
    - '2019-12-26'
    
    
  # Time Date
  - platform: time_date
    display_options:
      - 'time'
      - 'date'
      - 'date_time'
      - 'date_time_iso'
      - 'time_date'
      - 'time_utc'
      - 'beat'
      
      
  # Sun Angle
  - platform: template
    sensors:
      solar_angle:
        friendly_name: "Sun Angle"
        unit_of_measurement: '°'
        value_template: "{{ '%+.1f'|format(state_attr('sun.sun', 'elevation')) }}"  


  # Energie Beheer Wasdroger     
  - platform: template
    sensors:
      wasdroger_amps:
        friendly_name_template: "{{ states.switch.wasdroger.name}} Current"
        value_template: '{{ states.switch.wasdroger.attributes["current_a"] | float }}'
        unit_of_measurement: 'A'
      wasdroger_watts:
        friendly_name_template: "{{ states.switch.wasdroger.name}} Huidig Verbruik"
        value_template: '{{ states.switch.wasdroger.attributes["current_power_w"] | float }}'
        unit_of_measurement: 'W'
      wasdroger_total_kwh:
        friendly_name_template: "{{ states.switch.wasdroger.name}} Verbruik Totaal"
        value_template: '{{ states.switch.wasdroger.attributes["total_energy_kwh"] | float }}'
        unit_of_measurement: 'kWh'
      wasdroger_volts:
        friendly_name_template: "{{ states.switch.wasdroger.name}} Voltage"
        value_template: '{{ states.switch.wasdroger.attributes["voltage"] | float }}'
        unit_of_measurement: 'V'
      wasdroger_today_kwh:
        friendly_name_template: "{{ states.switch.wasdroger.name}} Verbruik Vandaag"
        value_template: '{{ states.switch.wasdroger.attributes["today_energy_kwh"] | float }}'
        unit_of_measurement: 'kWh'
        
  # Energie Beheer Wasmachine     
  - platform: template
    sensors:
      wasmachine_amps:
        friendly_name_template: "{{ states.switch.wasmachine.name}} Current"
        value_template: '{{ states.switch.wasmachine.attributes["current_a"] | float }}'
        unit_of_measurement: 'A'
      wasmachine_watts:
        friendly_name_template: "{{ states.switch.wasmachine.name}} Huidig Verbruik"
        value_template: '{{ states.switch.wasmachine.attributes["current_power_w"] | float }}'
        unit_of_measurement: 'W'
      wasmachine_total_kwh:
        friendly_name_template: "{{ states.switch.wasmachine.name}} Verbruik Totaal"
        value_template: '{{ states.switch.wasmachine.attributes["total_energy_kwh"] | float }}'
        unit_of_measurement: 'kWh'
      wasmachine_volts:
        friendly_name_template: "{{ states.switch.wasmachine.name}} Voltage"
        value_template: '{{ states.switch.wasmachine.attributes["voltage"] | float }}'
        unit_of_measurement: 'V'
      wasmachine_today_kwh:
        friendly_name_template: "{{ states.switch.wasmachine.name}} Verbruik Vandaag"
        value_template: '{{ states.switch.wasmachine.attributes["today_energy_kwh"] | float }}'
        unit_of_measurement: 'kWh'

  # Totaalverbruik
      totaal_verbruik_watts:
        value_template: '{%- if not is_state("sensor.wasdroger_watts","unknown") -%}  {{  ((states.sensor.wasdroger_watts.state | float) + (states.sensor.wasmachine_watts.state | float))| round(2) }} {%- endif -%}}'
        friendly_name: 'Totaal Verbruik'
        unit_of_measurement: 'W'
        
      totaal_verbruik_kwh:
        value_template: '{%- if not is_state("sensor.wasdroger_total_kwh","unknown") -%}  {{  ((states.sensor.wasdroger_total_kwh.state | float) + (states.sensor.wasmachine_total_kwh.state | float))| round(2) }} {%- endif -%}}'
        friendly_name: 'kWh verbruik Totaal'
        unit_of_measurement: 'kWh'   
        
      vandaag_verbruik_kwh:
        value_template: '{%- if not is_state("sensor.wasdroger_today_kwh","unknown") -%}  {{  ((states.sensor.wasdroger_today_kwh.state | float) + (states.sensor.wasmachine_today_kwh.state | float))| round(2) }} {%- endif -%}}'
        friendly_name: 'kWh verbruik Vandaag'
        unit_of_measurement: 'kWh'
        
  - platform: badnest
  
climate:
  - platform: badnest
    scan_interval: 10

### BINARY SENSORS ###

binary_sensor:

  # Wyze
  - platform: wyzesense
    device: "/dev/hidraw0"
    
  # Workday sensor
  - platform: workday
    country: NL
    workdays: [mon, tue, wed, thu, fri]
    excludes: [sat, sun, holiday]
    add_holidays:
      - '2019-12-26'
      - '2019-12-31'
1 Like