Better update for iOS battery state?

I am using sensor.<device_name>_battery_state to power my automations. Specifically I want my Blink cameras to arm when the battery_state goes “Charging” in the evening (I went to bed), and disarm when it goes to “Unplugged” in the morning (I woke up).
But the sensor is very slow to update. I often see from logs that it goes to Charging state about an hour after I plug my phone. And the same with when I unplug it. Is there any way to make this more robust?

1 Like

I believe that’s because the app only sends an update on major movement (gps location). With that info comes the battery level. Same was true for owntrack. so I stopped using this for automations…

Another issue is that it does not seem to change state to charging wirelessly, only when plugging in. I wanted to automate some lights when the iPhone was put on charging mat when going to sleep, but no luck…

I too had this issue, my best solution is to use a power monitor on the outlet the USB is connected to. This will tell you when the phone is plugged in as the power usage will go up. You will have to use something else for the morning…

I did right a python script for a raspberry pi, it could tell when a iphone was plugged into it and worked great. But the raspberry pi did not give enough power to charge the phone quickly (overnight was not bad but if I needed power during the day it was terrible).

I wonder if you could get a " USB Tester" (below) to send data to HA…

Just to let you guys know: Yu can accomplish a HA sensor update when charging or not charging using an iOS shortcut automation. This works regardless if you charge your phone wireless or with a cable.

Hope that helps.

2 Likes

Thanks for the heads up! I had the same problem and it works great with the shortcuts app!
My shortcut automation triggers a http binary sensor.

Here’s a screenshot of the HTTP part of the shortcut: shortcuts screenshot

I would recommend for others using the Home Assistant shortcut action “Update Sensors” to keep battery state updated as it doesn’t require the setup of webhooks or new sensors.

3 Likes