I’m trying to make a nice template for “Switch Humidifier” custom component.
I’m almost there, I have this:
Still, my sensor for the humidifier states as “Unavailable” every time it is on. When it is off I got the “IDLE” output, everything okay in that front.
What can I be missing in the code?
The template looks fine, however I do notice that your image shows an entity with the name Humidifier State when your template is Humidifier Inside Garden. Are you sure you’re looking at the correct entity?
Thank you for your answer @petro . Yes, in the image you see with the name I’m giving to it, but the entity is Humidifier Inside Garden. So the issue persists.
Template variable error: ‘state’ is undefined when rendering ‘{% if (is_state(‘switch.tasmota_2’, ‘on’)) %} {% if (state(‘sensor.tasmota_2_energy_power’) | int >= 15) %} Running {% else %} Out of water {% endif %} {% else %} IDLE {% endif %}’
@petro, somehow I managed to put it to work. Even if I slightly changed the code again, I think the solution haves to do with a deep reboot I made to the system, or anything with my Athom Tasmota Plugs. Anyhow, it is working except when the humidifier starts, it says “Out of Water” for 1 or two minutes, and only after it will say “running” as expected.
My slution for it was to create an automatization for notifying me when the humidifier gets out of water, only after 5 minutes with the “Out of Water” state. And thats good enough for me.
Thank you very much for your help, the case is solved
Here’s my final version of the code:
humidifier_inside_garden_state:
friendly_name: "Humidifier Inside Garden"
icon_template: >-
hass:air-humidifier
value_template: >-
{% if (is_state('switch.tasmota_2', 'on')) %}
{% if (states('sensor.tasmota_2_energy_power') | float <= 5) %}
Out of Water
{% else %}
Running
{% endif %}
{% else %}
IDLE
{% endif %}