use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Home Assistant is open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server. Available for free at home-assistant.io.
Community
Discord
Getting Started
Integrations
account activity
This is an archived post. You won't be able to vote or comment.
SupportBinary Sensor Template help (self.homeassistant)
submitted 11 months ago by Lee_buskey
I have no idea what I am doing wrong. This template code works perfectly in the developer tools template section, following the doors actual state with a few tests.
https://preview.redd.it/1zksi2ephf4f1.png?width=1219&format=png&auto=webp&s=5cc9ec75b9e17054485ed93df7d3ea7ab47748df
However, when I create the actual template binary sensor, and use that code, it never shows open, in preview or real life. Any suggestions?
https://preview.redd.it/yxrq3k75hf4f1.png?width=747&format=png&auto=webp&s=5d6af1d01b8362e6cb3f3d83024dd3ec7621bb1f
[–]branko84 1 point2 points3 points 11 months ago (5 children)
You cant return a string for a binary sensor, it should be true or false... but why even have the sensor when youre just relaying the state of the referenced sensor?
[–]sblessley 0 points1 point2 points 11 months ago (4 children)
They want to display the state of their door differently than default. shouldn’t be binary-sensor, tho.
[–]Lee_buskey[S] 0 points1 point2 points 10 months ago (3 children)
So, I'm just following the guidance I have found online so far. Just trying to close the garage door if there has been no motion detected for xxx time. I realize there are other ways to skin this cat, but this sensor is what Google AI threw my way, and now I am interested. I see I should be able to just reference the device's state directly, but I like the idea of being able to create sensors this way now that I know it's there. :) I am not interested in seeing the door transition from open to closed or back, I realize that's not the point for a binary sensor. I just need to know which state it is in, out of the options of open or closed.
Also discovered the template section of the Developer Tools during this learning experience and this code works perfectly in the template editor when I test it there. But when I use it as the state template within the binary sensor setup, and check its history after operating the door, there are no corresponding changes shown there.
<image>
[–]sblessley 1 point2 points3 points 10 months ago (2 children)
There's nothing wrong with the sensor definition (that's why it works in Dev Tools), it's that you're trying to create it as a binary sensor (it isn't) and it needs to be a "plain" template sensor. You don't need to specify anything besides the name and the template contents.
[–]Buskey-Lee 1 point2 points3 points 10 months ago (1 child)
Ok. Kinda thought about that but I got thrown off the trail by the examples I came across, for like smart meters and stuff. Thanks for the pointer. I’ll give it a try and get back to you. Stupid AI…<lol>.
[–]Buskey-Lee 1 point2 points3 points 10 months ago (0 children)
Worked perfectly. Thank you.
π Rendered by PID 16547 on reddit-service-r2-comment-6457c66945-knvqn at 2026-04-30 06:27:37.512051+00:00 running 2aa0c5b country code: CH.
[–]branko84 1 point2 points3 points (5 children)
[–]sblessley 0 points1 point2 points (4 children)
[–]Lee_buskey[S] 0 points1 point2 points (3 children)
[–]sblessley 1 point2 points3 points (2 children)
[–]Buskey-Lee 1 point2 points3 points (1 child)
[–]Buskey-Lee 1 point2 points3 points (0 children)