I am new to HA and have just began including some sensors using the REST sensor/binary sensor. The first effort went pretty well and I have successfully integrated a temperature sensor. I am, however, having some issues with a door sensor due to the state being reported as “present” and “not_present” instead of the “true/false” etc. Is there any way I can make this work? The state is now constantly reported as “closed”.
I’ve never used a REST sensor, but I’m guessing you could use value_template with the binary REST sensor to define the template for the value. Something like
That should work. It’s implied that when the value is not_present the sensor will be off because the template only evaluates to true when the value is equal to present. For a binary template sensor, true means on and false means off.
If you add device_class: door as well, you’ll end up with
present -> true -> on -> open
not_present -> false -> off -> closed
If you need it switched around so that present means closed, just replace present with not_present in the value_templateor change == to != and leave present.
Thanks alot for the help and syntax tip! It worked like a charm!
Just a general question also: Even though the sensor reports open for a short while (a few seconds, while opening a door), home assistant does not seem to record this. Is there any way of controlling how often or how you subscribe to these events?