dasshio: HassOS, VMDK - Status Code 401, Bad Request
Running HassOS VMDK 1.8, I get a status code of 401 status code after each button press.
{
"timeout": 10,
"buttons": [
{
"name": "Living Room | Accessory",
"address": "12:34:56:78:90:ab",
"domain": "switch",
"service": "toggle",
"service_data": "{\"entity_id\": \"switch.living_room_accessory\"}"
}
]
}
2018-07-23 22:44:25,412 | INFO | Living Room | Accessory button pressed!
2018-07-23 22:44:25,414 | INFO | Request: http://hassio/homeassistant/api/services/switch/toggle
2018-07-23 22:44:25,431 | INFO | Status Code: 401
2018-07-23 22:44:25,432 | ERROR | Bad request
2018-07-23 22:44:25,450 | INFO | Packet captured, waiting 10s ...
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 43 (4 by maintainers)
I am seeing the same thing here.
Log
I’m still able to manually make a service call to toggle the groups.
Edit: I saw the discussion going on in #40 and here, I’ve uninstalled and removed the repo, then rebooted HassIO, installed the repo and addon, saved the config, rebooted HassIO again, same problem unfortunately.
Edit 2: Seems like the internal API is rejecting the request for some reason. I’ve modified my buttons to make the request manually, by passing in the x-ha-access header, and calling the relevant API manually to temporarily fix this. My config now looks like this:
Just merged. Sorry guys but I was on holiday. Just released 0.3.1 with the fix. You’ll tell how it goes!
@e2m32 The code is correct, you just used the wrong header key.
x-hassio-keyis for the Hass.io API. Usex-ha-accessfor Home Assistant API requests. I just tested and it worked for me., headers={'x-ha-access': os.environ.get('HASSIO_TOKEN')}@maur54, @wwwebrat, @jmoery, @JesseWebDotCom here’s a work around until the internal api link is fixed.
Thank you @russjr08!
@danimtb set this up so the button can also call external api’s, not just the internal one provided for Add-Ins. If you have your HA API exposed, you can utilize that functionality to call it this way. If you’re not using a domain name, just use your HA’s internal IP address and drop https (assuming your not using SSL). I tried using https://192.168.x.x (internal IP), but I got an error.
Note that if you add users with the new authentication method that is coming soon, this will likely break your buttons. You’d have to update your headers.
An update for hassio has been released in order to fix the api issue https://twitter.com/pvizeli/status/1021854007546073088?s=21
Thanks @shoejosh! All these names, Hassio, Hassos, Home Assistant. Thanks for the explanation.
Hrm… Mine’s not working. Just updated to Hass.io Supervisor 121 (thats the version that showed up in my UI) and HA 0.74.1. I tried restarting the Dashio Add-on and my rPi. Anyone have any ideas? Roll back to Supervisor 120?
Same. HA 0.73.1 and was working great till yesterday. I don’t recall performing and updates which is why it’s a head scratcher that it just flat out stopped.
Working again!
The 0.3.1 release didn’t appear on hassio panel, but a reinstallation did the trick. Hours later the new version showed up.
Confirmed working here as well, thanks a bunch!
Working for me. Thanks Daniel.
@grantalewis, I wanted to make sure I could fix it first. Didn’t want to make any promises. As you can see, I needed some help.
Shoejosh did open up a PR for this, so looks like it just needs to be merged 👍
With @e2m32 suggestion now goes!!! Thanks!!
{ “timeout”: 2, “buttons”: [ { “name”: “son_UNO”, “address”: “FC:XX:67:XX:32:60”, “url”: “http://192.168.1.XXX:8123/api/services/light/turn_on”, “headers”: “{"x-ha-access": "xxxxx my password","Content-Type": "application/json"}”, “body”: “{"entity_id": "light.son_uno"}” }, { “name”: “son_UNO1”, “address”: “FC:XX:67:9B:XX:50”, “url”: “http://192.168.1.XXX:8123/api/services/light/turn_off”, “headers”: “{"x-ha-access": "xxxxx my password","Content-Type": "application/json"}”, “body”: “{"entity_id": "light.son_uno"}” } ] }
Add-ons communicating via
http://hassio/homeassistant/need to send the environment variableHASSIO_TOKEN(docs) as authentication. Not the users password.Please, update Hass.io supervisor to version 120 to solve this issue. No matter if you are running resinOS or hassOS. Thanks!