Hello,
I am trying to utilize the RESTful switch to read and control my garage door status based on a custom hardware I have built. I have used a Particle Photon form particle.io to build a garage door controller. HA provides me the below error on startup and never creates a ‘garage_opener’ entity.
2022-01-08 13:24:45 ERROR (MainThread) [homeassistant.components.rest.switch] No route to resource/endpoint: https://api.particle.io/v1/devices/<device-id-removed>/door?access_token=<access-token-removed>
I am able to use CURL on my PC and from the Terminal plugin in HA to access this endpoint.
My current configuration is this:
switch:
- platform: rest
resource: https://api.particle.io/v1/devices/<device-id-removed>/door?access_token=<access-token-removed>
state_resource: https://api.particle.io/v1/devices/<device-id-removed>/garageOpen?access_token=<access-token-removed>
name: garage_opener
method: POST
body_on: '{"args": "open"}'
body_off: '{"args": "close"}'
is_on_template: "{{ value_json.result }}"
headers:
Content-Type: application/json
I don’t fully understand why on startup HA is even accessing the ‘resource’ endpoint. Shouldn’t it be accessing the ‘state_resource’ endpoint to get the status?
Here is the output of the CURL commands showing this endpoint responding:
jason@MacBook-Air ~ % curl "https://api.particle.io/v1/devices/<device-id-removed>/garageOpen?access_token=<access-token-removed>"
{"cmd":"VarReturn","name":"garageOpen","result":0,"coreInfo":{"last_heard":"2022-01-08T22:26:20.508Z","connected":true,"last_handshake_at":"2022-01-08T16:26:59.310Z","deviceID":"<device-id-removed>","product_id":6}}%
jason@MacBook-Air ~ % curl -X POST "https://api.particle.io/v1/devices/<device-id-removed>/door?access_token=<access-token-removed>" -d "{\"args\":\"close\"}" -H "Content-Type: application/json"
{"id":"<device-id-removed>","connected":true,"return_value":0}%
This is a fresh HA install on a Raspberry Pi 3B if that helps. My searching has only led me to workarounds resolving this issue.
I currently am able to read the door status with a binary_sensor which is configured as below. The key here is that I am trying to add control functionality:
binary_sensor:
- platform: rest
resource: https://api.particle.io/v1/devices/<device-id-removed>/garageOpen?access_token=<access-token-removed>
method: GET
name: garage_door
value_template: "{{ value_json.result }}"
Any tips tricks or suggestions would be really helpful for me! Thank you!