I have created a sensor which derives its value from a template, to give a simple indication of whether we are currently away from home and are returning today.
I am also using the visual editor to create automations, which check this value to do things like put the heating on early. However my automations keep going wrong. When I look in the traces I think this is because I am getting the capitalisation wrong of ‘on’ and ‘off’, in different places.
I’ve seen that this problem is avoided when you use a binary sensor, as the visual editor knows what values are allowed (On, Off, Unknown, Unavailable).
Is there a way to define a binary sensor in YAML which gets its state from templating, similar to what I have already done? Or is there a way to define a set of valid values for a sensor which will show up in the dropdown of the visual editor?
Thanks for those pointers. I’ve been reading around the modern format for templating; although the web seems to be full of older examples rather than the modern ones, I think I have understood it.
However, when I try to define a binary sensor within my configuration.yaml I am getting an error message on the very first line of the new bit of code. I suspect I am making a really simple error - please can you help me work this out?