Problem with presence based lights

Hi,

I’m using presence based lights (https://home-assistant.io/components/device_sun_light_trigger/) For device tracker, I use ASUSWRT module.

Sometimes my wife’s phone disappears from the network and shown as not_home while my phone is still home. When my wife’s phone appears again in the network and its state changes to home, lights turn on while they shouldn’t, since my state was home during that time.

I feel like it should turn the lights on only if all devices weren’t present at home before. In my case since I was seen as at home all the time, my wife’s appearance shouldn’t change light state.

How can I fix the behavior, or am I misconfiguring something?

You can group your devices and use that instead. That way, only one of your devices need to be home for the automation to be marked as “home”.

I have done some similar stuff here:

https://github.com/joch/home-assistant-config/blob/master/automation/lights.yaml

And here:

https://github.com/joch/home-assistant-config/blob/master/automation/alarm.yaml

1 Like

I’ve already grouped them

device_sun_light_trigger:
  light_group: group.living_room_lights
  light_profile: energize
  device_group: group.household_mobiles

living_room_lights:
  name: Living Room Lights
  entities:
    - light.living_room_ceiling
    - light.living_room_window
  view: false
household_mobiles:
  name: Household Mobiles
  entities:
    - device_tracker.samsunggalaxys7
    - device_tracker.androidaa0200c920b1513b

Presence detection is always a troublesome beast to conquer and everyone seems to have varying degrees of luck with it but the majority that are successful use more than one platform for detection; I myself use iBeacons, Owntracks and Automatic (for my car) in conjunction and found it works better for me than using only one of them.

Using only the router and/or nmap is a problem cause of mobile phone’s power saving features that turn off wifi after a period of dormancy and therefore you’re suddenly showing as not home.

You need to pair presence detection via router with another method, most popular being Owntracks or GPSLogger

1 Like

I pair nmap and GPS logger but my wifes phone has upgraded to android 7 and it is a right ball ache. All night long it is on of on of on off on off because of the stupid doze feature turning off wifi. I’ve had to remove her phone from presence detection.

Anyone got a way round this? there was a disable app on android 6 but that doesn’t work on 7

My girlfriend and I both have v7.0 and never have this issue. In advanced wifi settings do you have an option for “Keep Wi-Fi on during sleep”? Mine is set to always and so is hers. We never have the lights turn off on us while were home.

yeah I have that set and it was fine with v6 but since it updated to v7 it is flipping. I’ve added GPSlogger to the whitelist, so will see what this does.

can you do me a favour and post your device_tracker: config please?

Not home right now, but I’m using the TP-Link component to track my devices. So maybe that has something to do with it?

hmm maybe.
but if you could post I’d be grateful. might have something to do with the consider_home or home_interval settings

Very possible, I’ll send you my config when I get a chance. If anything you could up those values and/or add a condition to your automations that makes sure you’ve been gone for 5+ minutes before it executes for example? Though that’s certainly a workaround.

I think the problem here is that even though someone is already at home, it turns on lights when another person comes home. In my opinion it shouldn’t change state. It should turn on the light only if no one was home before.

My girlfriend only uses wifi too so I set up the code to set her as “away” to only activate if she has been away for a set period of time. You can tweak how long yourself but 10mins works for our napping iphones.

Here is my trigger code: (note spacing is not correct because I don’t know how to properly post)
trigger:
- platform: state
entity_id: device_tracker.tracy
to: ‘not_home’
for:
minutes: 10

This then turns off or on a input.boolean that I use to detect if we are home or not for my light automations

Here’s my config

device_tracker:
  - platform: tplink
    host: 192.168.0.1
    username:
    password:
    interval_seconds: 10
    consider_home: 15
    track_new_devices: true

thanks… I tried and lowered my settings and then my phone started flipping as well :smiley:

device_tracker:
  - platform: nmap_tracker
    interval_seconds: 10
    consider_home: 300
    track_new_devices: no
    hosts:
      - 192.168.0.10
      - 192.168.0.14
      - 192.168.0.38
  - platform: gpslogger

that is mine and even with both phones using gpslogger, hers goes to sleep when not charging, so frustrating

how long does it go to sleep for? Your code there will only work if it only goes to sleep for 5 mins.

I am going to test out this and see if it works and what affect it has on my phone battery.