@senatorchimera wrote:
I am trying to automate my garage door and have a Raspberry Pi monitoring the door status and am not sure if I am doing it the right way. From what I can tell so far in Home Assistant, the best way to do this would be for me to create a REST binary_sensor in Home Assistant. The problem I have with that configuration is the REST binary_sensor is a polling service that polls every minute and not real-time. I would like for the Pi to push the door status on change. I am thinking using the Home Assistant REST API is the best way to keep the status real-time, but seem to be having some issues getting the correct syntax.
Here is my configuration:
configuration.yaml
binary_sensor: - platform: rest resource: http://192.168.1.6:5000/api/status/leftdoor method: POST name: Left Garage Door device_class: garage_door value_template: '{{ value_json.status }}'
I can call the endpoint using CURL and get the following:
curl --request GET 192.168.1.6:5000/api/status/leftdoor returns {"status":"Closed"}
I can call my home assistant API and get the following:
curl --request GET 192.168.1.216:8123/api/states/binary_sensor.left_garage_door returns {{ "attributes": { "device_class": "garage_door", "friendly_name": "Left Garage Door" }, "context": { "id": "a7a139b80bc14bee8e27ff24c5fe02a2", "parent_id": null, "user_id": null }, "entity_id": "binary_sensor.left_garage_door", "last_changed": "2020-03-20T16:46:47.789213+00:00", "last_updated": "2020-03-20T16:46:47.789213+00:00", "state": "off" }
Here is where I have an issue. I am not sure what to put in the Home Assistant REST API to properly show a changed status
When I post:
curl --request POST 192.168.1.216:8123/api/states/binary_sensor.left_garage_door
What do I send in the body?
{"state": "Closed"} or {"state": "off"}
neither seems to reflect the same status as the true closed status of the garage door.
Posts: 6
Participants: 3