Most of the time the sensor sensor.wasmachine_program_progress shows unavailable and when it runs it show the percentage.
I want to show “something” when unavailable is there. So I am struggling to get the value template syntax to get the status and translate that to “something” when it is unvailable.
We can start again, that’s why I called this topic a “struggle”. I do totally not get the logics behind getting a template sensor to work. I have REALLY tried (I am not going to get into that direction again).
I think I do not get the syntax/logics on how this language works and I must use it in order to “get what I want”. Every time I face such a thing I google around and copy-past stuff until it works.
So now I have this:
washmachine_percentage:
friendly_name: "Washmachine percentage ready"
device_class: #<What do I need for percentage>
value_template: >
{% is_state('sensor.wasmachine_program_progress', 'unavailable') %}
"0 %" #<--- here I want the value when unavailable shows
{% else %}
state #<--- here I want the percentage to show when there is
{% endif %}
help :-)?
EDIT:
Now have this rendering “nothing” (blank) when unavailable (currently) as I want. But I wonder if it will return the actual sensor output (percentage) when running:
That’s my point; none of the three types that report the value as a percentage (battery, humidity, power_factor) are a perfect fit for your application. Don’t use the device_class option for this sensor (unless you don’t mind having it displayed with a battery/humidity/power_factor icon).
I don’t know for sure. I never use them and I’m not sure what the state of the template sensor would be if the original entity was unavailable. I would think it would say ‘unavailable’ which is what the OP is trying to avoid.