Hi all,
Beginner here.
I am experimenting with simple automation for phone battery level notification.
For the purpose of learning I want to create simple automation which should notified my Android phone device when it’s battery level reaches threshold value during phone charging.
I try to do that by creating automation with trigger like so:
Put a condition to trigger this only in case phone is charging:
condition: state
entity_id: sensor.redmi_note_8_pro_battery_state
state: charging
Than I simply define an action to call notify service on phone.
When I trigger automation manually I get notification on my phone and that is the only thing that works here.
For the purpose of troubleshooting I try to completely remove condition statement and have battery level above 90% just to trigger notification in any case when battery level is above 90%, but nothing happens. Notification is never triggered.
Could you please try to explain why is that so and this suppose to work?
Another question related with phone notification in HA phone app.
I noticed that it can pass a several minutes from time I triggered notification manually to receive it on phone (I am not setting any offset).
If I open the phone app while I am waiting notification to arrive, it arrives immediately. Which makes me think that phone OS(Android) prevents notification or sets some lower prio for it. I allow background access of the HA phone app, it didn’t help. I try to play with Android notifications for HA phone app but didn’t manage to get results either.
This is the case for few automations I create. They just have delay and I am guessing it depends if the HA phone app is running on phone or it’s sleeping but that’s just me guessing.
The automation only trigger when the value goes from below the threshold to above the threshold and then only trigger again when it goes below the threshold and above the threshold again, so it wiöl not trigger when battery changes from 91 to 92 or from 95 to 94.
Did you try to remove the quotes around 90? Can you please ahow the full automation code.
Should be triggered only when state is changed from any value <= 90 to value > 90.
But it won’t be triggered if the value changes from 91 to 92 for example, like you said.
- id: '1607367241915'
alias: Notification for phone charging level
description: Notify when battery level reaches threshold during phone charging
trigger:
- platform: numeric_state
entity_id: sensor.redmi_note_8_pro_battery_level
above: '90'
condition:
- condition: state
entity_id: sensor.redmi_note_8_pro_battery_state
state: charging
action:
- service: notify.notify
data:
title: Battery level test
message: 'Battery level: {{states("sensor.redmi_note_8_pro_battery_level")}}%'
mode: single
But I noticed that phone won’t update sensors frequently and thus it happens that my notification arrives too late while the threshold is already crossed a while ago.
Is there a way to improve this?
I configured notifications according to your suggestion and completely removed battery saving on HA phone app. App was already configured to run in background so that part wasn’t an issue I would say.
I’ll test behavior and get back. I need to see real life scenario for full day or so.
Usually once phone is often used sensor updates are more frequent but once I leave it in peace for a while sometimes hours are needed for sensors update.
Regarding notification, I try to call service manually using Developer Tool with suggested settings:
title: test
message: "test123"
data:
ttl: 0
priority: high
and it really does trigger notification instantly.
Looks promising.
Here is my feedback after I tested automation for a while.
Notifications works flawlessly.
Battery sensor updates not quite good as I would like, but for sure it is better that my first attempts and I can make some use of it.
I noticed that I have to start HA app and it should always remain in the background (should not be cleared from background). That mostly worked ok, battery was slowly discharging and HA was able to follow battery level with minor deviations.
However, even with app in background, it happens sometimes that sensor won’t be updated for a long time… by that I mean hours… I don’t know why that is, but it happens sometimes during morning . Than I would have to open HA app on the phone again and I would be ok with sensor updates for rest of the day.
I removed restrictions for HA app for saving battery.
I implemented a different solution to this problem. Might not be the best one ou there. But in my case i needed to know when the battery is low so that i can start the charging plug ( this is used with my wall tablet dashboard), otheriwse if the level update didnt come, my battery would die out.
I implement a 10 minute check, and nd based on that i turned the plug on.