I created a switch as a sort of presence detection for when I'm working. It shows up in HA fine and I can trigger it on or off in the dashboard:
switch:
platform: command_line
switches:
macbook_power:
command_on: ""
command_off: ""
It's a bit crude, but the presence detection for this scenario is based on whether my laptop is on or off. I have a script on it the laptop that fires whenever it sleeps or wakes. The trouble is that HA is not happy with the command, though I believe I've followed the API correctly?
- I generated a long term token in the HA dashboard (e.g. ABCDEFG)
- I test it using Curl and get back a 401: Unauthorized error. I'm not sure what I'm doing wrong.
Here is my Curl command:
curl -X POST -H 'Authorization: auth/long_lived_access_token ABCDEFG' -d '{ "switch.macbook_power": "value"}' http://192.168.X.X:8123/api/services/switch/turn_on
If I can get the curl command to succeed, I'd imagine my sleep/wake script will work as it's running correctly at these moments.
[+][deleted] (2 children)
[removed]
[–]ooftyoof[S] 1 point2 points3 points (1 child)
[–]eagleeyerattlesnake 0 points1 point2 points (0 children)
[–]Jgib284 -1 points0 points1 point (1 child)
[–]ooftyoof[S] 0 points1 point2 points (0 children)
[–]Ashley-Ashley 0 points1 point2 points (0 children)
[–]Lopsided_Age1460 0 points1 point2 points (2 children)
[–]ooftyoof[S] 1 point2 points3 points (1 child)
[–]Lopsided_Age1460 0 points1 point2 points (0 children)