My washing machine is stating “unavailable” when the power is off, so I thought I would use this if state to either have On or Off for that entity. This one works great in the template editor, but how would it look if I want to put it in the configuration.yaml file?
{% if states (“sensor.siemens_wm14pihdn_68a40e60a7cb_bsh_common_setting_powerstate”) == unavailable %}
On
{% else %}
Off
{% endif %}
Yes. That can be accomplished with a YAML-configured Template sensor or binary sensor as shown in the documentation I linked above or through a Template Helper set up in the UI.
OK, sorry for the badly put questions, I was doing it via my tablet, not a good idea maybe… So here goes, from the begining:
I have the Home Connect Alt integration with the devices Dishwasher ang Washing machine. The dishwasher is working properly when off, but the washing machine just states ‘unavailable’ when the power is off. This is my cards in my dashboard when both machines are off:
That is why I was looking for the solution to make the statement ‘unavailable’ to say ‘Off’ instead, to make it more proper in the card.
This code (inserted in configuration.yaml) gives the code ‘On’ at my Card, even if the washing machine is off…
So, you want “unavailable” to return “off”; are there any other values that should return “off”.
Should all values other than “unavailable” just be returned as-is, or do they need to be modified as well? Keep in mind that only certain values, True, yes, on, enable or positive numbers, are rendered as “on” in a binary sensor.
What should happen if the original sensor is unknown? I would suggest you set that as the availability determining value, so you have an indicator that there is something wrong with the source sensor:
template:
- binary_sensor:
- name: “washing machine”
state: "{{ not states('sensor.siemens_wm14pihdn_68a40e60a7cb_bsh_common_setting_powerstate') in ('unavailable', 'unknown') }}"
Would also add, if you are not overly comfortable with adding sensors in yaml or just need a simple template sensor, you can use the template helper (just copy the bit in the curly brackets, including curly brackets) into the template line of the helper config.
Just to note, what you’re doing here is not best practice in general.
If an entity is unavailable, it normally does have reasons. In this specific case it seems like an error on the manufacturer side, as off should be off and not unavailable. Perfectly valid in this case, but shouldn’t be used otherwise…
Be careful with such things, they tend to haunt you later on…
And if I may offer one piece of really important advice: start now with something like a naming convention! You will get annoyed in the future, if you use such names like shown in your first post. I know, this is tedious, but the best way to handle this is with every new device, on first discovery, give it a name you can work with. Shorter and meaningful is the way you want.
It is an error from the manufacture, others have problems with the Siemens appliances according to the forum, so this is the best solution for me at the moment.
Actually , I have another friendly name for the entity, but it is in Swedish so I copied the original name for my first post