Trying to view template result on card

I have a system that triggers watering based moisture level. The moisture detection part is powered by a rechargeable battery that is charge by solar via TP4056. On that module there is a LED that indicates when it is charging and a different LED to indicate when fully charged. I have wired both LEDs to 2 IO pins of esp8266 and I currently view the status but not in a way that I want. This is the current view:
Instead, I would like to see only one line with a status of either ‘Charging’, ‘Not charging’ or ‘Fully charged’
In the Developer tools > Templates I have this code and it works:

{% if is_state("binary_sensor.04_charging", "On") %}
{% elif is_state("binary_sensor.04_full_charge", "On") %}
Fully Charged
{% else %}
Not Charging
{% endif %}

How do I get the result of this template to show on a card?

With a Mushroom template you can do it (here is my logic for one of my solar batteries)

{% if states('sensor.solax_battery_power_charge') | int(0) == 0 %}
{% elif states('sensor.solax_battery_power_charge') | int(0) < 0 %}
{% elif states('sensor.solax_battery_power_charge') | int(0) > 0 %}
{% endif %}


1 Like


Thanks for the quick response. I am looking into Mushroom cards, it can take me some time to understand well as what I need to display is based on a template resulting from the state of two entities.

EDIT: It actually took me 10 minutes to understand and working well. :+1:

1 Like