Using the my WiFi SSID for presence detection

Because you made it a binary sensor.
A binary sensor only has on/off, you give it home/not_home.

Hey guys I’m also having problems in setting this up.
I want to use the wifi_connection entity from the companion app.
HA shows the state properly so that’s not the problem.
From my understanding I would have to create a new sensor which
gives “home” or “not home” according to what the entity states.
I tried all the above samples.
What did work was to create an binary sensor in the configuration.yaml giving yes or no in respect to the entity state.
What does not work is to create a sensor in the sensor.yaml that would give “home” or “not home”.
I can add the code for a new sensor in the sensor.yaml without getting an error but obviously it doesn’t create a new sensor.
So what am I doing wrong?

Do you really need the sensor?
I just have a condition in my automations saying if wifi SSID == something

Actually I was asking myself this before.
And to achieve what I want this would be enough.
But on the other hand I want to make this like a “global variable” what decides a couple of things.
And I wanted to display this on my dashboard.

So where would I need to put the code for the sensor.
Inside he configuration.yaml but under sensors, right?

Ok, seems I’ve found a working solution.
Thanks anyway.

1 Like

Hi
Aware this is an old thread. I also want to use wife connection tell HA if I am home or not as GPS can be unreliable. I am not good with YAML, so I am doing this all from GUI. I made the following automation with GUI and I have copied the YAML. Would this not work?

alias: test wifi
description: “”
trigger:

  • platform: state
    entity_id:
    • sensor.haris_s22_wifi_connection
      to: Rxxxxx
      condition: []
      action:
  • service: device_tracker.see
    data:
    dev_id: c39bea1471dbfc2bf9d781b48
    location_name: home
    mode: single
1 Like

I use a binary sensor with a grace period / timeout of 180s / 3min to avoid changing to not_home in case I’m quickly outside or my phone disconnects wifi for a second, in combination with GitHub - pnbruckner/ha-composite-tracker: Home Assistant Composite Device Tracker and a timeout of 180 seconds (3 minutes)

First, I created a binary sensor:

#Device Tracker Home Assistant Companion App Wifi SSID
  - platform: template
    sensors:
      your_wifi_tracker_name:
        friendly_name: Your Wifi Tracker Name
        icon_template: >
          mdi:wifi
        value_template: >
          {% if "your_SSID" in states('sensor.your_ha_app_ssid_sensor') %}
            on
          {% elif not "your_SSID" in states('sensor.your_ha_app_ssid_sensor') and (as_timestamp(now()) - as_timestamp(states.sensor.your_ha_app_ssid_sensor.last_changed)) < 180 %}
            on
          {% else %}
            off
          {% endif %}

Second, I used the above sensor in the composite tracker to create a device_tracker (which you then can finally add to a person for tracking):

composite:
  default_options:
    time_as: device_or_local
    require_movement: false
  trackers:
    - name: Your Device Tracker Name
      time_as: local
      entity_id:
        - entity: binary_sensor.your_wifi_tracker_name
          all_states: true
1 Like

On automations I use a Condition Template:

condition: template
value_template: "{{ is_state('sensor.someones_iphone_ssid', 'Your SSID') }}"

You must give location permission “Allways” and “Precise Location”.

Hello everyone…
I know this already some dated subject, but i try to follow it to get better presence detection.
GPS sucks for that.
So i followed everything in here so far and got something but not all…
for example…if i try the “all_states: true” i always get indentation issue and other errors and also dont really understand the background of that value in full.
So some more explanation would be appreciated.
And since i am doing two devices via composite joined gps and ssid, how do i know that it is actually doing it?
Does my home server monitor the ssid changes or the app?
Cause the app has no background running data allowed since it uses data volume galore…15 gig the last month…it seems to stream my cameras to the phone even when not looking at them or app in background…
Here my code:
Maybe someone can use it or sees an issue with it that i can correct and learn something

composite:
  default_options:
    time_as: device_or_local
    require_movement: false
  trackers:
    - name: Jan_home_or_away
      time_as: device_or_local
      entity_id: 
        - device_tracker.janss10      
        - binary_sensor.Jans_phone_tracker
     #     all_states: true
    - name: Nico_home_or_away
      time_as: device_or_local
      entity_id:
          - device_tracker.nicosphone       
          - binary_sensor.Nicos_phone_tracker
        #  all_states: true
################################################################################
# Sensor section start
################################################################################

binary_sensor:
  - platform: ping
    host: 192.168.178.60
    name: "Pro6bak"

  - platform: template 
    sensors:
      jan_presence_sensor:
        friendly_name: Jans_phone_tracker
        icon_template: >
          mdi:wifi
        value_template: >
          {% if (states('sensor.jans_s10_wifi_connection') == "7390AP") or (states('sensor.jans_s10_wifi_connection') == "Netgear63") or ((states('sensor.jans_s10_wifi_connection') == "7390AP_5GHZ")) or ((states('sensor.jans_s10_wifi_connection') == "7390AP_5aGHZ"))  %}
            home
          {% elif not (states('sensor.jans_s10_wifi_connection') == "7390AP") or (states('sensor.jans_s10_wifi_connection') == "Netgear63") or ((states('sensor.jans_s10_wifi_connection') == "7390AP_5GHZ")) or ((states('sensor.jans_s10_wifi_connection') == "7390AP_5aGHZ")) and (as_timestamp(now()) - as_timestamp(states.sensor.your_ha_app_ssid_sensor.last_changed)) < 180 %}
            home
          {% else %}
            not_home
          {% endif %}
  - platform: template 
    sensors:
      nico_presence_sensor:
        friendly_name: Nicos_phone_tracker
        icon_template: >
          mdi:wifi
        value_template: >
          {% if (states('sensor.nicolasphone_wifi_connection') == "7390AP") or (states('sensor.nicolasphone_wifi_connection') == "Netgear63") or ((states('sensor.nicolasphone_wifi_connection') == "7390AP_5GHZ")) or ((states('sensor.nicolasphone_wifi_connection') == "7390AP_5aGHZ"))  %}
            home
          {% elif not (states('sensor.nicolasphone_wifi_connection') == "7390AP") or (states('sensor.nicolasphone_wifi_connection') == "Netgear63") or ((states('sensor.nicolasphone_wifi_connection') == "7390AP_5GHZ")) or ((states('sensor.nicolasphone_wifi_connection') == "7390AP_5aGHZ")) and (as_timestamp(now()) - as_timestamp(states.sensor.your_ha_app_ssid_sensor.last_changed)) < 180 %}
            home
          {% else %}
            not_home
          {% endif %}

# Sensors section end
################################################################################

Hello everyone

I would like to use SSID location to turn on/off the Caddy add-on, so that my instance is reachable from the outside only when I’m not in my home.

I set up a binary sensor as shown above, but as soon as my smartphone disconnects from the router the sensor is no more updated, and never reach the “off” state.

Is there any way I can make this work?

AFAIK my router is not supported by the tracker platform; I might set up a fixed IP for the smartphone and use it with the PING integration, but I’d rather use something that does not require a manual update when I change the device.

Unfortunately I cannot use a templated value with the ping integration, otherwise I’d just PING the IP assigned by the router to my phone …

Thank you for sharing this, it was super helpful.