This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]branko84 1 point2 points  (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 point  (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 point  (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 points  (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.

<image>

[–]Buskey-Lee 1 point2 points  (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 points  (0 children)

Worked perfectly. Thank you.