I have been searching for days, found many similar post, but when I try the code, it doesn’t work, must of the code I got is from 2023 post, so I believe it’s old and not working on 2026, but of course, I don’t understand much of coding.
So basically I have a washing Machine sensor that works great, the only thing is, even if I switch the Washing Machine off, it stay in “Power Off” but when I reboot Home Assistant it become unavailable. If I turn it on for a few seconds it come back working, but I hate “unavailable”.
When I turn it on, even for 3 seconds.
So I tried lot of code but nothing works, always now showing errors but just doesn’t work.
template:
sensor:
name: “Washing Fixed”
state: >
{% set current = states(‘sensor.front_load_washer_current_status’) %}
{% if current not in [‘unavailable’, ‘unknown’] %}
{{ current }}
{% else %}
{{ states(‘sensor.front_load_washer_fixed’) }}
{% endif %}
Not really, I mean I want the card always showing but power off or on if washing, I don’t want to see unavailable when I reboot HA or when the Washing Machine is off.
it’s hard to tell what might be the problem if there is one with the template since you didn’t properly format your code block but it looks like your indentation is off:
template:
- sensor:
- name: “Washing Fixed”
state: >
{% set current = states(‘sensor.front_load_washer_current_status’) %}
{% if current not in [‘unavailable’, ‘unknown’] %}
{{ current }}
{% else %}
{{ states(‘sensor.front_load_washer_fixed’) }}
{% endif %}
But also I don’t know if it will fix the problem.
I think you have the logic backwards in the template.
try this:
template:
- sensor:
- name: “Front Load Washer Fixed”
state: >
{% set current = states(‘sensor.front_load_washer_current_status’) %}
{% if current not in [‘unavailable’, ‘unknown’] %}
{{ states(‘sensor.front_load_washer_fixed’) }}
{% else %}
{{ current }}
{% endif %}
I didn’t catch it myself but you’re using the wrong type of quotes. I call them “fancy” quotes that are the type that some word processor software uses. you need the “plain” type of quotes that things like notepad uses.
it’s hard to show the difference but this should show it:
‘.....’
vs
'...'
with the first ones you can see the they are more curved.
the second ones are more straight.
that’s the danger in using stuff copied from other people. you should usually just try to re-type it yourself or fix the quotes if you get this type of error.
try this:
template:
- sensor:
- name: “Front Load Washer Fixed”
state: >
{% set current = states('sensor.front_load_washer_current_status') %}
{% if current not in ['unavailable', 'unknown'] %}
{{ states('sensor.front_load_washer_fixed') }}
{% else %}
{{ current }}
{% endif %}
it’s not the keyboard that you’re using it’s the word processing software. both kinds of quotes come from the same character key.
I don’t think so.
I just tried the exact code that I posted above and it shows up in my system as expected.
has the ‘sensor.front_load_washer_current_status’ ever been not “unavailable” yet?
if not then the sensor won’t haved a good current state to fall back to.
IOW, if the sensor never got changed to something other than unknown or unavailable then that’s what the current state will be that it keeps using. either you need to wait till the previous sensor becomes available again or try to set it manually in the developers tools page and see if that changes anything.
I turned the Wash Machine on and the original entity goes to Power_Off and the fixed goes to unknown, once I reboot home assistant both go back to unavailable.
Hi SoNyz85, I also have a sensor to tell me when my Washing machine (in the laundry downstairs) has finished … in my case its a separate wi-fi smart power plug detecting whether the washing machine is drawing current.
That sounds correct to me. “Unavailable” means that Home Assistant does not know that information.
The Washing machine sends messages to Home Assistant when its status changes, or in some cases at a regular interval - there is not a constant connection because this would fill your wi-fi so nothing else could communicate.
When you reboot Home Assistant, the washing machine does not know that HA was rebooted - and since nothing has changed at the washing machine it has no reason to send an update to HA.
If Home Assistant does not know the status of the washing machine, all it can show is “unavailable”
Similarly, the wi-fi link between a device and HA is not guaranteed. If there is a weak wi-fi signal strength, too much interference, or the wi-fi channel is busy … well the device has tried to send its update - yet HA doesn’t know the current status.
It would be more constructive to find out why the device is unavailable.
How often does the device send an update to HA? Some update regularly, while others only when the value changes. note 1
Is there any message in the Log (Settings / System / Logs) ?
Are you rebooting HA more often than necessary ?
Note 1: I have found it useful to display the “Last Updated” as Secondary Information in an Entities card
I use the washing machine once a week, so once I use it and finished my washing, I switch it off and the state is Power Off, which is fine, but if during the week I reboot HA it shows unavailable again.
Now, what I want is, that even if I reboot HA, I don’t want to see unavailable because it shows question mark and doesn’t show the background images.
I understand that the Washing machine doesn’t comunicate to HA if it is off for long time, but is there a way to change the state automatically on boot?
If I go to state, change state and from unavailable I change it to Power Off, all the images in the background come back.
So if i can setup on boot change state of the washing machine to Power Off, I will be happy with that.
Otherwise every time I reboot HA I have to do it manually or turn on the washing machine, even for 3 seconds and it comes back Power Off.