Hi,
Given following URL, which turns a device on (value=true) and off (value=false):
http://IP:PORT/set/abc.def?value=true
This works fine when calling in web browser or executing in the Home Assistant Terminal: curl http://IP:PORT/set/abc.def?value=true
configuration.yaml:
switch: # https://www.home-assistant.io/integrations/switch.rest/
- platform: rest
name: "666"
resource: http://IP:PORT/set/abc.def
state_resource: http://IP:PORT/get/abc.def # The resource or endpoint that reports the state if different from resource. Used by is_on_template
body_on: 'value=true'
body_off: 'value=false'
is_on_template: '{{ value_json.val }}'
headers:
Content-Type: application/json
verify_ssl: false
When adding a card, it reflects the status (on / off) correctly (with a delay, of course) if I turn the device on/off e.g. through the web browser. So, this works fine.
However, when clicking on the HA card to turn on, it does not turn the device on, following error in the log:
Logger: homeassistant.components.rest.switch
Source: components/rest/switch.py:172
Integration: RESTful (documentation, issues)
First occurred: 2. November 2021, 19:21:29 (5 occurrences)
Last logged: 18:40:58
Can't turn on http://IP:PORT/set/abc.def. Is resource/endpoint offline?
Calling http://IP:PORT/set/abc.def?value=true
in web browser returns
{"id":"abc.def","value":true,"val":true}
Response header per browser (Edge):
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Content-Type: application/json; charset=utf-8
Date: Wed, 03 Nov 2021 17:47:05 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 60
Now I am really stuck and have no clue how to investigate further to get it working. I also tried the following for body_on/body_off in the config, but this did not work either:
body_on: '{"value": "true"}'
body_off: '{"value": "false"}'
Any help would be very much appreciated.
Thanks!