Hello,
I found this, wich seems to be what I need to match the status of my lights in ha with my home automation system : REST API | Home Assistant Developer Docs
So I created this :
turn_lights_hallway_on:
url: http://192.168.1.6:8123/api/states/light.lights_hallway
method: POST
headers:
authorization: 'Bearer ABC'
content-type: 'application/json'
payload: '{"state":"on"}'
I replace ABC by a Long-Lived Access Token.
And do a rest command in my automation :
- service: rest_command.turn_lights_hallway_on
data: {}
But I get an error :
Logger: homeassistant.components.http.ban
Source: components/http/ban.py:84
Integration: HTTP (documentation, issues)
First occurred: 08:37:12 (1 occurrences)
Last logged: 08:37:12
Login attempt or request with invalid authentication from 192.168.1.6 (192.168.1.6). Requested URL: ‘/api/states/light.lights_hallway’. (HomeAssistant/2022.10.5 aiohttp/3.8.1 Python/3.10)
Logger: homeassistant.components.rest_command
Source: components/rest_command/init.py:137
Integration: RESTful Command (documentation, issues)
First occurred: 08:37:12 (1 occurrences)
Last logged: 08:37:12
Error. Url: http://192.168.1.6:8123/api/states/light.lights_hallway. Status code 401. Payload: b’{“state”:“on”}’
What did I wrong ?