Are you trying to make a Template Sensor Helper? If so, did you apply an inappropriate device class. (If you applied any device class, the answer is “yes”.)
I want to make a template binary sensor using a couple of parameters (time and day) to determine if a certain light should be on or not. I need to use these conditions in a couple of places, but want to only have one place to actually set the values being used - hence the template binary sensor.
In fact, states(‘sensor.time’) is now working as it should. I originally copied it from somewhere and pasted it into the template, but I suspect the quotes were wrong, having been ‘smartened’ along the way, which is not visibly obvious. I re-typed them as actual single quotes and it now works.
I should have thought of that before as it’s not the first time this sort of thing has caught me out.
{{ now().time() }} will give you the current time sensor.time only is available if you’ve set up the integration. Of which I see basically no use unless you want a sensor to display on a dashboard.
For usage in templates just use now() to retreive the current time or date
Good point, although I don’t recall setting up the integration. As now() is apparently the built-in method, I’ll use that.
Can I throw in another question here though. I know binary sensors basically just return true or false, but the type chosen means one sees other descriptions, like ‘no light’ or ‘light detected’ for a light. Is there a type that can be used to simply show true or false?
Although this will be used to control lights, it is not detecting anything. I just want a yes|true or false|no to be the choices offered and shown in the UI, but none of the types offered seem to be that simple. Is there one?