I’ve added several sensors using rest and they work fine but now I’m trying to add a simple leak detector binary sensor to the same rest section . While it works with this:
The binary sensor shows “Off” so I’m trying to get it to display “Dry” and “Wet”. When I try adding any logic for the binary sensor, rest fails after restarting HA even though it passes in DT.
One way to do this is to amend your template binary sensor to add a unique_id
Docs are on this page:
When your sensor has a unique_id Then you can edit the device from the UI to make it type: moisture which probably has the icons colors and states you’re looking for without a lot of work.
I’ve tried using unique_id’s but it always errors and fails to load anything in the rest section until I take it out. I’ve used unique_id’s with other entities like in modbus and it works fine but never had luck with rest.
In reading through all the posts I can’t really tell if unique id is supported in rest or not. It also says in the documentation that you can use any of the sensor configurations in rest like device class etc. but I’ve never been able to without errors.
So after lots more playing with different configuration I came up with what worked and what didn’t for me.
What I found was that using RESTful rest: configuration to create multiple sensors using a single resource endpoint is very limited in what can be configured for the sensors. It won’t accept unique_id’s, device_class or any of the sensor configurations without breaking rest so it doesn’t load. What was throwing me was that I was following the documentation in the RESTful section which says:
“sensor list (optional)
A list of sensors to create from the shared data. All configuration settings that are supported by RESTful Sensor not listed above can be used here.”
The only way I could get things to work was creating individual sensors using the RESTful sensors option and this allowed me to use all the configuration variables that I needed including unique_id’s: