Hopefully somebody can help as this is driving me nuts! The following code doesn’t work for me, I get this error:
Failed to perform the action badnest.boost_hot_water. invalid boolean value [[[ if (states['water_heater.1st_floor_thermostat_hot_water'].state === "on") return "false" else return "true" ]]] for dictionary value @ data['boost_mode']. Got None
Any ideas? My code below which I’m testing in Actions. If I edit the code to just set boost_mode: true, it works… so I’m guessing I have a problem with the conditional statement or the type of data its expecting.
I’m just testing it in developer tools at moment with the idea to create a button card to switch on and off. If I remove the IF statement and just set boost_mode: true, it works successfully turning the hot water on.
I copied this code from another post for same integration, but cannot get it to work.
Checking the state of the entity returns on or off as a string.
You cannot use templates in the Action tool (afaik).
If you test with the template debugger, it won’t work either, as your code is javascript.
Your code will only (maybe) work in a dashboard, with the context (custom component) of the thread you copied the code from. HA doesn’t support javascript natively (afaik)
The original code was as follows which was for a card in a dashboard. I’ve tried this code in a button card, replacing for my entity, but I get the same error message.
As already said above, you can’t use esphome code (javascript) in HA, since esphome uses javascript which ha doesn’t recognize. Yaml code in ha is different, like
Thanks. Sorry for being a real donut here. But it should work in a custom card right or is this the same as an “Action” ? e.g. I’ve tried using this in a button card, and I get exactly the same error message.
I presume this is the only way to add a conditional input
When button card is pressed, the error is the same i.e. invalid boolean value:
Failed to perform the action badnest/boost_hot_water. invalid boolean value {% if states(‘water_heater.1st_floor_thermostat_hot_water’) == “on” %} true {%else%} false {%endif%} for dictionary value @ data['boost_mode']
Not necessarily, templates are not supported in the actions of most cards… even custom cards that support templates in other parts of their configuration.
You need to use the method Tom described previously.
Ok thanks, will put in a script and see how I go, as probably it will make easier to set heating schedules.
Unfortunately the person who originally posted this code has not replied. However I think I just figured out why their code didn’t work for me - because he was using the custom button-card… which allows javascript… !
Why not install “custom button card” then ? It’s by far the most usable card in HA (or should i say hacs). I use it in, i guess, appr. 70% of my dashboard cards.
Yes I have done it, thank you! However I think having the script will allow me to set automations to use same function, as there is no on/off with this integration for nest. Basically you have to boost the hot water function for a given time.