Hi all,
I want to set a Hue scene when I OR my wife enter at home after sunset.
I used multiple triggers 'cause on HA site I read “Whenever one of the triggers fires, your rule is executed.”, one trigger is a zone trigger, the other one is nmap trigger.
I turned off wi-fi on my iPhone to set it “not_home” and after I turned on wi-fi, but the scene is not activated, if I activate the automation manually it works.
Here my code:
alias: Rientro a casa
trigger:
- entity_id: device_tracker.n9q7n16708000135
event: enter
platform: zone
zone: zone.home
- entity_id: device_tracker.damianostation
from: not_home
platform: state
to: home
condition:
- condition: state
entity_id: sun.sun
state: below_horizon
action:
- alias: ''
data:
group_name: Sala da pranzo
scene_name: 70 per cento
service: hue.hue_activate_scene
You need to check if/when the device_tracker entity associated with your iPhone changes state between home and not_home. It’s very possible turning the phone’s WiFi off and on didn’t cause a state change in the device_tracker. You may have to leave it off longer (for the state to change to not_home), and you may have to wait a while after turning it on (for the state to change back to home.) WiFi based presence detection (e.g., NMap) on phones, and iPhones in particular, are notoriously slow to respond from what I read.
Yes, I waited till the state changed to not_home and then I turned on wi-fi on my iPhone, so the state changed to home but the scene was not activated…
Did you actually see the state change to home, or did you assume it must have because you turned the wi-fi back on? Just because you turned the wi-fi back on does not mean the corresponding device_tracker entity (immediately) changed state to home.
If you iPhone is represented by device_tracker.damianostation, and you made it actually change states to not_home and then home, and sun.sun’s state was below_horizon, then the automation should have triggered (if it was on), and the action should have run. If it didn’t run then one of those assumptions are false.
I have the sensor in my HA interface and I waited till it changed to “fuori”, italian state for not_home, and then I turned on my wi-fi and the state changed to “a casa” (at home), I checked it some hours after sunset and the sun was obviously below_horizon. So, I was sure about the state of my nmap sensor.
The code in the config file is:
Then if you haven’t changed the automation since your original post, and you verified that device_tracker.damianostation changed from not_home to home, and you verified that sun.sun is below_horizon, then the only other possibilities I can think of that would prevent the action from running are: 1) the automation is off, or 2) you need to quote not_home and home in from: and to:.
I know that some states can get automatically converted to True or False if not quoted, so you might try adding quotes to these lines like this:
- entity_id: device_tracker.damianostation
from: 'not_home'
platform: state
to: 'home'
If that doesn’t fix it, and you’ve verified the automation is turned on, then I’m stumped.
It seems now it works, I don’t know if quotes really fix this issue, anyway every time I edit the automation using the UI HA removes the quotes and I need to edit the file manually