Utility meter helper kwh

Syntax error with this - what are wrong?

{{ ‘Charging’ if is_state(‘input_boolean.charging_status’, ‘on’ AND state_attr(‘device_tracker.tmxxxxxxxxxxxxx_position’, ‘home’) elseif ‘Extern Charging’ state(‘input_boolean.charging_status’, ‘on’ AND state_attr(‘device_tracker.tmxxxxxxxxxxxxx_position’, ‘not_home’) else ‘Not Charging’ }}

Please help, Tanks

`

`

Haven’t tested anything but looks like a missing close bracket before each AND?

And elif not elseif

Ignore previous two comments. This from the post referenced earlier works fine in the template editor

{% if is_state('binary_sensor.dave_s22_wifi_state','on') and is_state('sensor.dave_s22_wifi_state','MyHomeWIFIName') %}
on
{% elif is_state('binary_sensor.brian_pixel6_wifi_state','on') and is_state('sensor.brian_pixel6_wifi_connection','MyHomeWIFIName') %}
on
{% else %}
off
{% endif %}

Change the sensor names and on and offs to Extern Charging etc and it should work!
(famous last words)

I had/have no idea what the syntax would be to do it in one line - template editor is a great place to try things out but I couldn’t get anywhere with one line approach.

Good luck

This works fine for me :wink: Thanks for helping.


data:
option: >-
{% if is_state(‘input_boolean.charging_status’,‘on’) and
is_state(‘device_tracker.xxxxxxxxxxx_position’, ‘home’) %}
Charging {% elif is_state(‘input_boolean.charging_status’,‘on’) and
is_state(‘device_tracker.xxxxxxxxxxx_position’, ‘not_home’) %}
Extern Charging {% else %} Not Charging {% endif %}