Thank you so much for the advice and the Template Editor that will save headache!
yes it was made by chatgpt lol i thought i was pretty valid but i guess i was wrong.
the sensor i’m trying to create is indeed a "if water is higher then 7 for 1 minuted then turn to on"so i can make a shower flow
You’re right, but don’t do the other thing either. It’s much easier to start from scratch than from the nearly-but-really-not-at-all-correct output from that thing, particularly if you don’t admit that it created it.
So the only change to the template sensor above should be to change delay_off to delay_on. The idiot robot’s code, if it worked, would switch on as soon as the usage went above 7 then not go off for a minute after it dropped again.
Using delay_on means that it must stay above 7 for a minute before turning on.
It was, though, because I had to try to figure out what the .state and .last_changed was trying to do. I would have been able to solve the initial requirements quicker (and more accurately ref delay_on/off) without that interim step.
oh oke, its fine i thought i was helping by trying with “stupid robot ai” but next time i will just ask how to approach my idea and go from there! thanks Troon!
thanks! i actually just read the forum post before posting and figured it was totally fine using chatgpt as a starting point but not to help people (which makes sense)
but i totally get both your points now that chatgpt just sucks with home assistant scripts (and perhaps with coding in general but I’m not at liberty to say that as i am no programmer)
I encourage you to study the two documentation sections I posted above. They’re vital to understanding how to correctly reference an entity’s properties and to compose templates. They’ll help you avoid the mistakes ChatGPT made when it produced that faulty example.