Hi,
I have a question about sensors from the companion app and how the sensors’ values are propagated in HA for being used in automations.
Specifically, I created an automation that would turn on the light next to my bed at the same time my alarm rings on my (Android) phone. So I
- Enabled that sensor on the phone (it grabs the correct time of the next alarm),
- Added Android System and the alarm app I use to the
allow list
(not sure if actually necessary, but oh well…), - Set the sensor update frequency to
fast while charging
and connect my phone to a charger to make sure that sensors are updated every minute, - Gave the HA app
background access
to continuously run in the background, - Activated the
next alarm
sensor in themobile app
integration, and - Verified that the phone’s sensor changes show up in HA in the logbook (they do and they show the correct values, e.g.
2024-03-11T07:00:00+00:00
) - Verified that both phone and HA instance are in the same timezone and have the correct time
Now, my automation looks like this:
alias: Morning light
description: ""
trigger:
- platform: time
at: sensor.my_phone_next_alarm
condition: []
action:
- service: light.turn_on
metadata: {}
data:
brightness: 120
transition: 15
target:
device_id: 019abc309c83cf3152e60b37ab1ea554
mode: single
As already specified, when I set the alarm on my phone, the updated value shows up in HA instantaneously.
Now, when I set my alarm for “in two minutes” to test everything, the automation won’t work. My alarm goes off on the phone - but with the new next_alarm time having reached the logs of HA already, the automation isn’t triggered. I tried multiple times and eventually gave up somewhat frustrated.
I was VERY surprised the next morning when the light indeed turned on with my alarm - even though I didn’t change anything in the automation.
So my question is this:
- Is there a certain delay between sensor data being available for automations? (Is this a bug?)
- How can I mitigate this?