Home Assistant Phone charging automation
Phone charging state and the battery %
Built by Sevagjb
Published 20 May 2023 · updated 24 May 2023 · 4 downloads
when you start charging it will publish the state and the battery %
when your phone battery is below 40% will trigger to publish
when the battery is full,
Copy and paste the Yaml code into the automation
only you have to change the phone sensor as this:
-sensor.iphone_battery_state
-sensor.iphone_battery_level
you can change the time pattern, the battery threshold (40%) and the text as you like.
enjoyed
:)
6wq2N5Nlo7KV.yaml · 2.3 KB
alias: ""
description: ""
trigger:
- platform: time_pattern
minutes: /7
- platform: state
entity_id:
- sensor.iphone_battery_state
to: Charging
condition: []
action:
- choose:
- conditions:
- condition: template
value_template: |-
{% if states('sensor.iphone_battery_level' ) |float <40 %}
true
{%- endif %}
sequence:
- service: mqtt.publish
data:
payload: &amp;amp;amp;amp;gt;-
{"text":"My iPhone is {{ states("sensor.iphone_battery_state")
}} {{ states('sensor.iphone_battery_level', "state" ,
'unit_of_measurement' ) }} ","icon":"12832","color":
"#b93232","pushIcon":2,"repeat":3,"textCase":2,"textOffset":33}
topic: awtrix_light/notify
alias: " MQTT: Publish Reed"
- conditions:
- condition: template
value_template: |-
{% if states("sensor.iphone_battery_state") =="Charging" -%}
true
{%- endif %}
sequence:
- service: mqtt.publish
data:
payload: &amp;amp;amp;amp;gt;-
{"text":"My iPhone is {{ states("sensor.iphone_battery_state")
}} {{ states('sensor.iphone_battery_level', "state" ,
'unit_of_measurement' ) }}
","icon":"1095","pushIcon":2,"repeat":3,"textCase":2,"textOffset":33}
topic: awtrix_light/notify
alias: " MQTT: Publish White"
- conditions:
- condition: template
value_template: |-
{% if states("sensor.iphone_battery_state") =="Full" -%}
true
{%- endif %}
sequence:
- service: mqtt.publish
data:
payload: &amp;amp;amp;amp;gt;-
{"text":"My iPhone is {{ states("sensor.iphone_battery_state")
}} {{ states('sensor.iphone_battery_level', "state" ,
'unit_of_measurement' ) }} ","icon":"12126","color":
"##22aa13","pushIcon":2,"repeat":3,"textCase":2,"textOffset":33}
topic: awtrix_light/notify
alias: " MQTT: Publish Green"
mode: single
These icons belong on the device, in /ICONS. Each one is at
most 32×8
pixels — shown here at actual proportions, magnified.
1095.gif
8×8
12126.gif
8×8
12832.gif
8×8