At home or not at home problem

Hi,

i have tried different ways to check if someone is at home or away. all ways are not working fine:

  • device tracker via ping to mobile device ip
  • mobile app device tracker
  • nmap device tracker

all three ways are showing not the correct status. sometimes it shows away when i am at home and sometimes not.

is there a way to do that working to 100%? i have a nokia 7.2 and a samsung a520 handy and a easybox from vodafone.

greetings

Well, if your phone does not respond to a ping, there is either a problem with your phone or with your networkā€¦

I would seriously check that ā€¦.

Modern phones will turn off the WiFi when in deep sleep.

I find that monitor, which uses Bluetooth, is the most reliable method. The mobile app works well if you use the value of the WiFi SSID rather than the device tracker.

Hi,

ssid is a very good idea. how do i configure that?

I can recommend to combine two sensors, one network based and one gps based (companion app) in a person entity.
They are almost never both wrong at the same time.
I actually use the SSID as the network based device tracker, by switching a ā€œdummy deviceā€ state through an automation:

  - id: presence_set
    alias: presence_set
    mode: restart
    trigger:
      - platform: state
        entity_id: 
          - sensor.seanpixel3a_wlan_verbindung
          - device_tracker.seanpixel3a
      - platform: homeassistant
        event: "start"
    action:
      - choose:
          - conditions:
              - "{{states('sensor.seanpixel3a_wlan_verbindung') == 'SSID'}}"
            sequence:  
              - service: device_tracker.see
                data:
                  dev_id: sean_dummy
                  location_name: "home"
          - conditions: 
              - "{{states('sensor.seanpixel3a_wlan_verbindung') != 'SSID'}}"
              - "{{states('device_tracker.seanpixel3a') != 'home'}}"
            sequence:
              - service: device_tracker.see
                data:
                  dev_id: sean_dummy
                  location_name: "not_home"

This would need a customization, te be recognized as a network based device_tracker:

homeassistant:
  customize:
    device_tracker.seanpixel3a_dummy:
      source_type: router

Thanks for sharing!
This works indeed more precise. :+1:

1 Like

hi,

thx, is this configured in configuration.yaml?

Yes, this is an automation and a customization in configuration.yaml

hi,

i have added the folllowing code now to my configuration.yaml

- id: presence_set
    alias: presence_set
    mode: restart
    trigger:
      - platform: state
        entity_id: 
          - sensor.nokia_7_2_wifi_connection
          - device_tracker.nokia_7_2
      - platform: homeassistant
        event: "start"
    action:
      - choose:
          - conditions:
              - "{{states('sensor.nokia_7_2_wifi_connection') == '-Pandora-'}}"
            sequence:  
              - service: device_tracker.see
                data:
                  dev_id: rene_dummy
                  location_name: "Home"
          - conditions: 
              - "{{states('sensor.nokia_7_2_wifi_connection') != '-Pandora-'}}"
              - "{{states('device_tracker.nokia_7_2') != 'Zu Hause'}}"
            sequence:
              - service: device_tracker.see
              
homeassistant:
  customize:
    device_tracker.rene_dummy:
      source_type: router

but code check says

end of the stream or a document separator is expected at line 78, column 1:
- id: presence_set
^

got it running now :slight_smile: butā€¦

entity device_tracker.rene_dummy is showing now ā€œHomeā€. entity device_tracker.nokia7.2 is showing ā€œZu Hauseā€ but when i use entity device_tracker.rene_dummy now in my person settings the person is showing as ā€œunknownā€.

Any ideas what i did wrong?

did you run the automation?
If your state didnā€™t change, the trigger would not have fired jet, and the entity rene_dummy would not be created jet.

Also the state in the condition should be ā€˜homeā€™ not ā€™ Zu Hauseā€™

- "{{states('device_tracker.nokia_7_2') != 'home'}}"

You can check the correct states in dev-tools. The frontend shows localized and device-specific strings that cannot be used in templates.

Hi, thx a lot! the ā€œzu Hauseā€ was the problem. Chnaged it to ā€œhomeā€ and its working fine now.

when i want to add a second SSID, would this be the correct way:

action:
      - choose:
          - conditions:
              - "{{states('sensor.nokia_7_2_wifi_connection') == '-Pandora-'}}"
             - "{{states('sensor.nokia_7_2_wifi_connection') == '-Pandora-EXT'}}"
            sequence:  
              - service: device_tracker.see
                data:
                  dev_id: rene_dummy
                  location_name: "Home"
          - conditions: 
              - "{{states('sensor.nokia_7_2_wifi_connection') != '-Pandora-'}}"
             - "{{states('sensor.nokia_7_2_wifi_connection') != '-Pandora-EXT'}}"
              - "{{states('device_tracker.nokia_7_2') != 'Zu Hause'}}"
            sequence:
              - service: device_tracker.see

another question: for my wife i still have only the mobile app device tracker in use. but it shows ā€œhomeā€ since a few days continously. but thats wrong, she is/was not allways at home. she is every day out of home for more than 8 hours.
any ideas what could be the problem?

No, this would not work (at least for the first condition) because multiple conditions are always ā€œANDedā€, and your phone will never be in two WLANs at the same time.
You could write something like

"{{ states('sensor.nokia_7_2_wifi_connection')  in  ['-Pandora-','-Pandora-EXT'] }}"

As to your wifeā€™s device_tracker: No Idea. Maybe the app doesnā€™t have the appropriate permission?
The app needs the permission to ALWAYS access the location and to run in the background ,though I canā€™t seem to find the latter right now.

and for the second condition i use ā€œnot inā€ instead of ā€œinā€?

No, in the second condition you want them to be AND, so you just leave it, as it is.

Edit: that was stupid of me. Yes, you use ā€œnot inā€.