So i tried making a sensor that says when my phone battery is high, medium or low.
This is the Code.
Battery:
friendly_name: Battery Status
value_template:
'{% if state_attr("sensor.hannes_iphone_battery_state_2", "battery") >= 70 %} Battery is high
{% elif state_attr("sensor.hannes_iphone_battery_state_2", "battery") <= 30 %} Battery is low
{% else %} Battery is medium
{% endif %}'
In the template editor it just worked fine.