Device tracker, trigger on either one not_home, or both home, but not if one is home

Strange…

It works fine for me…

that is why i go hmmmm

and it was also the reason for

no offence taken btw…

According to Group - Home Assistant (home-assistant.io)
view is not a variable.
Try and remove/comment that line.

that was it.

now i will rewrite the automation itself…

so i ended up with:

groups.yaml

person_trackers:
  name: Person Trackers
  entities:
    - person.tina_andersen
    - person.bo_herrmannsen_5

the automation itself:

alias: Tænd lys når hjemme
description: ''
trigger:
  - platform: state
    entity_id: group.person_trackers
    to: home
condition:
  - condition: sun
    before: sunrise
    after: sunset
action:
  - type: turn_on
    device_id: ****
    entity_id: light.kitchen_1
    domain: light
    brightness_pct: 60
  - type: turn_on
    device_id: ****
    entity_id: light.kitchen_2
    domain: light
    brightness_pct: 60
mode: single

my lights are grouped allready in phoscon hence that i work directly with lights, or so it would seem

Should work. But since they are device trackers based on GPS then you could get lag.

You could add router device trackers to the group that detects if you connect to wifi, that could be faster.

If you have the companion app installed you can use the wifi state which probably is the fastest to update of them all.

how much could the lag be?

the home area is bigger than it should be, so there is a chance that before we get to the garage in front of the appartment and close the gate and get to our appartment it would update

the area covers the next street befoure ours

we both have the app installed, so if the lag is to big we could go that route

Yes if you can connect to the wifi outside the apartment.
Usually you can but it has to be a few meters to give some effect.

If you go that route you just add the sensor for wifi ssid in the app and look for state change = wifi name as another trigger to your automation.

But GPS lag can be quite significant.
I have had less lag using the companion apps device tracker than Google maps tracker.
But can’t say for sure which is better.
I recently got a new phone and it made a significant change to the better.
Now I get a new update every ~100 m when driving

both our phones are also new, the old ones was worn out and the plastic started to crack and fall apart

so i think that with gps and the area being so big by the time we get to our door it will be fine.

if not, wifi is barely ok at the garage, but by the time we get to the staircase its ok

so only time can tell if i need to add it as a trigger

There is no harm in adding it. All triggers are “or”, so whatever happens first will trigger the automation.

image

easy enough :smiley:

but thinking of it, when at mom-in-law the ssid is the same, but then we are not home
will have to look at what the other sensors are

ahh wifi_bssid

will try that one instead as that is Unique

You can also log in to the router and change the name.
But that will affect all wireless devices you have.

yep, more trouble that it’s worth

i wanted to do the same when leaving…

ie i made a dublicate and then said when not_home switch off lights

using the wifi will make that happen a lot faster, but given that when driving away it might connect and disconnect from wifi a few times can i add a delay before new changes are considered a trigger?

image

is what i have in mind,

now also thinking that if one is home and the other needs to go and pick up a parcel
with the current setup would that not switch off the lights?

It sucks… But you only do it once.
I would create two device trackers that is controlled by automations.
The device trackers only need home/not home state so it’s not that hard.

Example:
Template device_tracker - Feature Requests - Home Assistant Community (home-assistant.io)

But in your case the trigger has to be wifi bssid.
Then you can add these two device trackers to your group and all logic will be maintained by the group (and work as you expect).

I actually can’t find where I created a device tracker.
The only place I can see anything regarding one of the trackers I have is in the known_devices.yaml.

kraftan:
  name: "Kraftan"
  picture: /local/kraftan3.png
  icon: mdi:golf-cart
  track: true

This is the device tracker that is updated when her phone disconnects from BT in the car so that it “parks” her car on a map.
Yes… it’s needed.

i can only trigger once? or what do you mean?

and by 2 device trackers i assume you mean one with bssid and the other home/not_home?

You only do the configuration once. It’s a lot of work but since you only do it once it’s just a matter of getting it done.

One for you and one for her.
From the linked thread:

action:
    - data_template:
        dev_id: richard
        location_name: >
          {% if is_state('binary_sensor.richard', 'on') -%}
            home
          {%- else -%}
            not_home
          {%- endif %}

As you can see the location is updated with home or not home

Yours should be something like:

action:
    - data_template:
        dev_id: richard
        location_name: >
          {% if state('sensor.sm_a515f_wifi_forbindelse', 'YOUR WIFI BSSID') -%}
            home
          {%- else -%}
            not_home
          {%- endif %}

ahh now i get it

so i create one automation for me and one for her

and in each i just put in:

action:
    - data_template:
        dev_id: richard
        location_name: >
          {% if state('sensor.sm_a515f_wifi_forbindelse', 'YOUR WIFI BSSID') -%}
            home
          {%- else -%}
            not_home
          {%- endif %}

??

of course i need to update the names in them so they match my setup… ie dev_id needs to change from richard to our names :smiley: