Home Assistant General

Create a Long Access Token in /Profile and replace long_access_token below.

On Windows you can not use single quotes around the json so all single quotes must be escaped.

Replace entity_name with the name of the entitiy you want to set.

The whole lot must have no new line characters if using at batch or powershell call.

curl -X POST
-H "Authorization: Bearer <em>long_access_token</em>"
-H "Content-Type: application/json"
-d "{"state": "on", "attributes": {"backup-a": "ok"}}"
http://homeassistant.local:8123/api/states/<em>entity_name</em>

For more information see https://developers.home-assistant.io/docs/api/rest/

 

Another option is to use the Powershell invoke-restmethod option see

https://docs.microsoft.com/en-gb/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.1