#Device unplugged automation triggered 20 minutes after it happened

1 messages · Page 1 of 1 (latest)

normal remnant
#

Originally posted this in https://discord.com/channels/330944238910963714/1289180644294787142 - it was suggested that I cross-post here since it's related to the App on my Android phone.

I have an automation that resets a counter when I unplug my phone. It's been working great until this morning. I woke up (and took my phone off the charger) at 06:28 when my alarm went off, but the automation ran at 06:55.
Any ideas what could have caused this? It's been running fine for quite some time - including yesterday morning.

alias: FreeMan is awake
description: >-
  Reset light dimming when phone unplugged between 4am and 1hr after
  sunrise
trigger:
  - type: not_plugged_in
    platform: device
    device_id: 0de3dc2943fa2181779f2b0378115fde
    entity_id: 80a5b5d22d86d3ae9ddcdcdbc604ccd6
    domain: binary_sensor
condition:
  - condition: sun
    before: sunrise
    before_offset: "+1:00:00"
    enabled: true
action:
  - data: {}
    target:
      entity_id: counter.morninglightdivisor
    action: counter.reset
mode: single

(Yes, I know the comment says after 4am, but there's no code to support that. The problem with comments...)

Attached is the logbook entry and the trace timeline showing when it actually triggered.

As suggested in the original post, I've confirmed that there was no OS update overnight (though that's happened before and the event still fired as expected) and I've confirmed that the setting to allow HA to run in the background at all times is on.

haughty tartan
#

It could be something as simple as network latency/network outage. (That would be my initial impression given the description). Did this only happen once or has it been consistent?

normal remnant
#

Sometimes, it seems to take as much as a whole minute for the system to register that I've unplugged my phone, this time it took almost 30 minutes to register.
It's never been this bad before - usually it's within seconds.
This is the only time that I'm aware of that it's taken more than a minute to register.

haughty tartan
#

Yeah, the minute is normal. Some of my mobile sensors (on iOS) can take up to 5-6 minutes to register, but that's an issue on my end. I would wait to see if this happens again. If it doesn't, I'd chalk it up to network congestion or just simple instability (ISP having issues, etc).

normal remnant
#

Yeah, I'm willing to chalk it up to "computers, can't live with 'em, can't live without 'em", but wanted to be sure there wasn't something that someone else might have noticed that might cause this.
I no longer get any notification of application updates on my phone, so there might have been an app update that I wasn't aware of that might have borked things - that type of thing.

subtle venture
#

so the device being plugged in should be an instant updte for android actually

#

depending on the device you may need to turn off battery optimization features and things like data saver etc.. so the app can run freely in the background

hallow shoal
#

Did you disconnect the power from the charger, or the charger from the phone?

Chargers have capacitors, which could conceptually tell the phone that it was still charging if the charger was still connected to the phone and the phone was fully charged, so not actually draining those capacitors.

What time was sunrise today in your part of the world?

normal remnant
#

It's on a wireless charger, so I simply picked it up.
Sunrise is ~7:40am

normal remnant
normal remnant
#

pixel 8

subtle venture
#

Did you check the background access tile in companion app settings?

#

It's separate from the setting you mention

normal remnant
#

ummm... rummaged about a bit, don't see that setting. Is it in the HA app or is it a Google setting?

#

Ah, found it! Yes, it appears to be set.
Home Assistant has access to run in the background
Doesn't look like it can be set there, just reporting what's been set in the Google settings.

subtle venture
#

thats fine as long as you see the checkmark there 🙂

#

the only thing to check next is the device logs when the issue occurs

#

the OS should be waking up the app with an intent about the charger being connected or not and thats what triggers the app to update, the companion app logs will show that

#

they are found under the troubleshooting section and unfortunately do not go very far back