Yeah… Thats how it is configured for a while now (+2year). Anyway… i made a workaround that works pretty accurately.
Im just sending an mqtt msg from my android via tasker when the phone connects/disconnects from the wifi.
Yeah… Thats how it is configured for a while now (+2year). Anyway… i made a workaround that works pretty accurately.
Im just sending an mqtt msg from my android via tasker when the phone connects/disconnects from the wifi.
I would like to know how to achieve this. Now the entity is an input_boolean each person is displayed as a toggle switch.
I could not find a way to change this to display like a device tracker would with Home and Away.
Could anyone help with this as I would like to have this display like a device tracker at the top of the screen? It does not have to be Home/Away as an on/off type Check Mark icon would be OK.
You can create a template sensor to mark home
when the input_boolean
is on and away
otherwise.
Thanks for this. I will look into creating this template sensor.
Sure!
You will need 3 profile.
Profile 1, name it "Close to Home"
NET Location based, make it a 3km radius around your home
Enter action
Wifi on action
Leave action
If variables HOME = 0 then Wifi off
Profile 2, name it "at Home"
Wifi connected. Set all your home wifi connection here, be based on MAC addresses
Enter action
Variable set HOME to 1
Profile 3, name it "Security"
Wifi connected. Set all your home wifi connection here, be based on MAC addresses
Enter action name it “Unlock”
Wait 2
if Locked = 0 then Stop task Unlock, end if
MQTT publisher send “home” data (addon) (Enter your mqtt info and etc)
Vibrate t500
Variable set LOCKED = 0
OPTIONAL -> Say: “Welcome Home!”
Leave Action, name it "Lock"
Variable set HOME = 0
wait 10 sec
If HOME = 0 then
MQTT publisher send “not_home” data
Vibrate t500
Variable set LOCKED = 1
OPTIONAL -> Say: “Locking down!”
You need Profile 2, because otherwise when your phone roams between wifi AP-s, it would instantly fire the “not_home” command.
Im using this 3 profiles for 2years without a single problem.
NOTE: It will fire the profiles after you reboot your phone while at home!
To counter this, you can do a 4th profile with DEVICE BOOT with this sequence: Set variable DEVICEJUSTBOOTED = 1, wait 2mins, Set variable DEVICEJUSTBOOTED = 1. Also in Security Profile, Unlock action, at if statement add an extra conditon DEVICEJUSTBOOTED = 1 with OR statement.
If you got stuck somewhere, just reply here! I’m happy to help!
Thank you for this, this helped me along for my presence detection system. The problem I had with yours was on the away part. It would trigger if any one of the sensors were ‘away’. I found that things like wifi sleep on a phone would give a false positive.
I started looking for a way to only trigger ‘away’ when all of the configured sensors were ‘away’. I came up with a solution using a value template for the away trigger.
Below is my automation code.
-alias: "Away"
condition:
condition: state
entity_id: input_boolean.home
state: 'on'
# Will only trigger if all are 'not_home'
trigger:
platform: template
value_template: "{% if (is_state('device_tracker.1','not_home')) and (is_state('device_tracker.2','not_home')) and (is_state('device_tracker.3','not_home')) %}true{% endif %}"
action:
service: homeassistant.turn_off
entity_id: input_boolean.home
- alias: "Home"
condition:
condition: state
entity_id: input_boolean.home
state: 'off'
# Will trigger if any of the below are 'home'
trigger:
- platform: state
entity_id: device_tracker.1
state: 'home'
- platform: state
entity_id: device_tracker.2
state: 'home'
- platform: state
entity_id: device_tracker.3
state: 'home'
action:
service: homeassistant.turn_on
entity_id: input_boolean.home
This is a good idea, I also go to test look, thank you!
for
should take care of wifi sleeping issues. Moreover, I have updated the sensors to take care of such issues and you can find the updated automations here.
this is right
(is_state(‘device_tracker.2’’,‘not_home’)) device_tracker.2 behind You more than one ’
{%- if states.input_boolean.rashmihome.last_changed -%}
{{ (as_timestamp(now()) - as_timestamp(states.input_boolean.rashmihome.last_changed)) > 300 }}
{%- else -%}
true
{%- endif -%}
what does this mean? thank you
It checks if the input_boolean.rashmihome
was changed in the last 5 minutes and prevents frequent changes.
No, a typo while transferring and anonymising the code here. Fixed now
good :咧嘴笑:
I want to share my best practice when dealing with presence detection and multiple trackers.
I have been a long time user now and my biggest issue have been presence detection.
When you have a family of 4 persons, with all diffrent devices (Apple, samsung, oneplus, sony) and so on, all the devices respond diffrent to diffrent device trackers.
The easy part is to detect when a device is home.
Using asuswrt, ping, owntracks, tasker (on android), bluetooth_tracker and nmap_tracker
My biggest problem is all the false “away” signals because some phone goes in to some powersave / doze mode or somehow just disconnects from the network. Or owntracks not update the location or the gps signal is weak and gives a position outside my home zone.
I guess im not the only one that have a lot of these false “away” entries in your logs, and if you have automations depending on these statuses it can give you some trouble…
My so far best sollution was when i finaly got the idea to use my hallway motoion sensor as a condition.
I dont know why i didn’t think of it earlier… Because no one can leave the house without triggering the hallway motion sensor.
So adding this condition reduced my false aways ALOT…
There are still some false ones, because some nightly trips to the bathroom will allso trigger the hallway motion sensor. but this could be totaly removed if i get my self a door sensor, or a electric door lock to use as the condition instead.
This method allso reduced the time it sometimes took to trigger the away…
On both asuswrt and ping i use to have quite big delays “consider_home” values to remove some false triggers before, but now when i use both asuswrt and ping with the hallway motion sensor as a condition i get some acceptable results.
would you mind giving me a sample snippet for how you implement this?
I am a noob and it seems like the more complicated I make my automation’s the more likely they are to fail, so while I could muddy through it myself, I would like to see your working elegant code.
Thanks,
The code is available in the first post or the linked repo. Everything is working well, so all you need to do is change the entity_id
for it to work for you.
ah ok, thanks. Btw your repo is what I have modeled like 99% of my HA setup after, so thanks for sharing everything!
I am glad you found it useful