Giter VIP home page Giter VIP logo

Comments (43)

russjr08 avatar russjr08 commented on July 23, 2024 7

I am seeing the same thing here.

{
  "timeout": 5,
  "buttons": [
    {
      "name": "Bathroom",
      "address": "38:F7:3D:7B:91:99",
      "domain": "script",
      "service": "toggle",
      "service_data": "{\"entity_id\": \"script.toggle_bathroom\"}"
    },
    {
      "name": "KimsToggle",
      "address": "00:FC:8B:7C:A8:24",
      "domain": "light",
      "service": "toggle",
      "service_data": "{\"entity_id\": \"light.kims_light\"}"
    },
    {
      "name": "RJToggle",
      "address": "18:74:2E:89:54:BA",
      "domain": "light",
      "service": "toggle",
      "service_data": "{\"entity_id\": \"group.bedroom\"}"
    }
  ]
}

Log

2018-07-23 21:43:14,608 | INFO | Packet captured, waiting 5s ...
2018-07-23 21:43:19,612 | INFO | Starting sniffing...
2018-07-23 23:14:47,797 | INFO | Bathroom button pressed!
2018-07-23 23:14:47,798 | INFO | Request: http://hassio/homeassistant/api/services/script/toggle
2018-07-23 23:14:47,806 | INFO | Status Code: 401
2018-07-23 23:14:47,806 | ERROR | Bad request
2018-07-23 23:14:47,810 | INFO | Packet captured, waiting 5s ...
2018-07-23 23:14:52,815 | INFO | Starting sniffing...
2018-07-23 23:16:42,428 | INFO | RJToggle button pressed!
2018-07-23 23:16:42,428 | INFO | Request: http://hassio/homeassistant/api/services/light/toggle
2018-07-23 23:16:42,440 | INFO | Status Code: 401
2018-07-23 23:16:42,440 | ERROR | Bad request
2018-07-23 23:16:42,443 | INFO | Packet captured, waiting 5s ...
2018-07-23 23:16:47,448 | INFO | Starting sniffing...

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:

{
  "timeout": 5,
  "buttons": [
    {
      "name": "Bathroom",
      "address": "38:F7:3D:7B:91:99",
      "url": "http://localhost:8123/api/services/script/toggle",
      "headers": "{\"x-ha-access\": \"YOURPWHERE\"}",
      "body": "{\"entity_id\": \"script.toggle_bathroom\"}"
    },
    {
      "name": "KimsToggle",
      "address": "00:FC:8B:7C:A8:24",
      "url": "http://localhost:8123/api/services/light/toggle",
      "headers": "{\"x-ha-access\": \"YOURPWHERE\"}",
      "body": "{\"entity_id\": \"group.kimsroom\"}"
    },
    {
      "name": "RJToggle",
      "address": "18:74:2E:89:54:BA",
      "url": "http://localhost:8123/api/services/light/toggle",
      "headers": "{\"x-ha-access\": \"YOURPWHERE\"}",
      "body": "{\"entity_id\": \"group.bedroom\"}"
    }
  ]
}

from dasshio.

danimtb avatar danimtb commented on July 23, 2024 6

Just merged. Sorry guys but I was on holiday. Just released 0.3.1 with the fix. You'll tell how it goes!

from dasshio.

e2m32 avatar e2m32 commented on July 23, 2024 5

@maur54, @wwwebrat, @jmoery, @JesseWebDotCom here's a work around until the internal api link is fixed.

Thank you @russjr08!

{
  "timeout": 20,
  "buttons": [
    {
      "name": "mybutton1",
      "address": "AB:CD:EF:GH:IJ:00",
      "url": "https://<myhasubdomain>.duckdns.org:8123/api/services/light/toggle",
      "headers": "{\"x-ha-access\": \"my_ha_api_paswd\",\"Content-Type\": \"application/json\"}",
      "body": "{\"entity_id\": \"light.bathroom\"}"
    }
   ]
}

@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.

from dasshio.

shoejosh avatar shoejosh commented on July 23, 2024 5

@e2m32 The code is correct, you just used the wrong header key. x-hassio-key is for the Hass.io API. Use x-ha-access for Home Assistant API requests. I just tested and it worked for me.

, headers={'x-ha-access': os.environ.get('HASSIO_TOKEN')}

from dasshio.

adonno avatar adonno commented on July 23, 2024 4

An update for hassio has been released in order to fix the api issue
https://twitter.com/pvizeli/status/1021854007546073088?s=21

from dasshio.

russjr08 avatar russjr08 commented on July 23, 2024 2

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.

from dasshio.

e2m32 avatar e2m32 commented on July 23, 2024 2

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?

from dasshio.

e2m32 avatar e2m32 commented on July 23, 2024 2

Thanks @shoejosh! All these names, Hassio, Hassos, Home Assistant. Thanks for the explanation.

from dasshio.

danimtb avatar danimtb commented on July 23, 2024 1

Please, update Hass.io supervisor to version 120 to solve this issue. No matter if you are running resinOS or hassOS. Thanks!

from dasshio.

balloob avatar balloob commented on July 23, 2024 1

Add-ons communicating via http://hassio/homeassistant/ need to send the environment variable HASSIO_TOKEN (docs) as authentication. Not the users password.

from dasshio.

maur54 avatar maur54 commented on July 23, 2024 1

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"}"
}
]
}

from dasshio.

russjr08 avatar russjr08 commented on July 23, 2024 1

Shoejosh did open up a PR for this, so looks like it just needs to be merged 👍

from dasshio.

e2m32 avatar e2m32 commented on July 23, 2024 1

@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.

from dasshio.

BertrumUK avatar BertrumUK commented on July 23, 2024 1

Working for me. Thanks Daniel.

from dasshio.

russjr08 avatar russjr08 commented on July 23, 2024 1

Confirmed working here as well, thanks a bunch!

from dasshio.

forast3r avatar forast3r commented on July 23, 2024 1

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.

from dasshio.

barefootpookie8 avatar barefootpookie8 commented on July 23, 2024

I am also getting this same message.

{
"timeout": 20,
"buttons": [
{
"name": "keurig1",
"address": "00:FC:8B:63:AC:9A",
"domain": "light",
"service": "toggle",
"service_data": "{"entity_id": "light.ge_appliances_zll_light_0002e915_1"
}
]
}

from dasshio.

HudsonMC16 avatar HudsonMC16 commented on July 23, 2024

This has something to do with the authorization settings in Hass. I don't think add-ons may use hard-coded API key anymore. I'm not at home, so cannot test, but I think you need to either update your config to use legacy auth or the dasshio Dev needs to update the add-on to use the new token/key auth method. https://developers.home-assistant.io/blog/2018/07/02/trying-new-auth.html

from dasshio.

danimtb avatar danimtb commented on July 23, 2024

@HudsonMC16 Thanks for the information link. Following the instructions there it should be fine setting in the configuration.yaml:

homeassistant:
  auth_providers:
   - type: legacy_api_password

I can guess this issue comes after updating home assistant to 0.74.
I havent tried the solution yet (still in 0.73) and I was not aware this was a breaking change in Hass.io

from dasshio.

e2m32 avatar e2m32 commented on July 23, 2024

I was in HA v0.73.2 and was having this issue

from dasshio.

e2m32 avatar e2m32 commented on July 23, 2024

@danimtb, Just gave this a test. No dice. :-(

homeassistant:
  auth_providers:
   - type: legacy_api_password

It was working fine in 0.73.2 like @russjr08 said, then it just stopped working. I thought maybe I should update to 0.74... obviously that didnt work. :-( Not sure what's going on here with the API.

from dasshio.

adonno avatar adonno commented on July 23, 2024

same issue hassio 0.74.0 on hassos

from dasshio.

pyrosmiley avatar pyrosmiley commented on July 23, 2024

Bumping/subscribing for the same problem -- just coming back with "Bad Request." legacy_api_password did nothing, unfortunately.

from dasshio.

e2m32 avatar e2m32 commented on July 23, 2024

Just attempted rolling back to 0.73.2, 0.73.1, and 0.73.0

All are not working. Same error:

2018-07-24 14:10:21,022 | INFO | Request: http://hassio/homeassistant/api/services/switch/toggle
2018-07-24 14:10:21,066 | INFO | Status Code: 401
2018-07-24 14:10:21,067 | ERROR | Bad request

From the system log:
18-07-24 18:12:29 WARNING (MainThread) [hassio.api.proxy] Unknown HomeAssistant API access!

from dasshio.

e2m32 avatar e2m32 commented on July 23, 2024

Just looking at this doc: https://developers.home-assistant.io/docs/en/hassio_addon_communication.html

It looks like the api call is missing the HASSIO_TOKEN

" Use this URL: http://hassio/homeassistant/api and internal communication is redirected to the right place. The next stept is to add homeassistant_api: true to config.json and read the environment variable HASSIO_TOKEN and use this as Home-Assistant password."

Could this be related to the SSL issue that they found pre-0.73.2? Maybe they broke this on purpose? Or maybe the HASSIO_TOKEN is there and I just don't know what to look for?

Just tossing out ideas. I'm not sure how HASSIO_TOKEN would be implemented... my guess is that it would have to be passed to the header for the value x-ha-access.

from dasshio.

JesseWebDotCom avatar JesseWebDotCom commented on July 23, 2024

After updating hassio my logs are flooded:

18-07-24 22:21:40 WARNING (MainThread) [hassio.api.proxy] Unknown HomeAssistant API access!

from dasshio.

JesseWebDotCom avatar JesseWebDotCom commented on July 23, 2024

But the dash buttons now work!

from dasshio.

maur54 avatar maur54 commented on July 23, 2024

Also for me the same error

2018-07-25 19:12:29,375 | INFO | Reading config file: /data/options.json
2018-07-25 19:12:29,379 | INFO | Starting sniffing...
2018-07-25 19:12:54,758 | INFO | son_UNO button pressed!
2018-07-25 19:12:54,759 | INFO | Request: http://hassio/homeassistant/api/services/light/turn_on
2018-07-25 19:12:54,818 | INFO | Status Code: 401
2018-07-25 19:12:54,819 | ERROR | Bad request
2018-07-25 19:12:54,857 | INFO | Packet captured, waiting 2s ...
2018-07-25 19:12:56,861 | INFO | Starting sniffing...

Dasshio 0.3.0
Home Assistant 0.74.1
Hass.io supervisor Version 121
System Resin OS 2.3.0+rev1

from dasshio.

wwwebrat avatar wwwebrat commented on July 23, 2024

Same here:

2018-07-25 20:54:41,796 | INFO | Request: http://hassio/homeassistant/api/services/homeassistant/toggle
2018-07-25 20:54:41,855 | INFO | Status Code: 401
2018-07-25 20:54:41,857 | ERROR | Bad request
2018-07-25 20:54:41,892 | INFO | Packet captured, waiting 20s ...
2018-07-25 20:55:01,914 | INFO | Starting sniffing...

Haome Assistant: 0.74.1 (also on the version before)
Dasshio: 0.3.0
Supervisor: 121
Host: Resin OS 2.3.0+rev1

from dasshio.

jmoery avatar jmoery commented on July 23, 2024

Same issue here. Have everything update to current versions but bad request coming back.

HA 0.74.2
Dasshio: 0.3.0
Supervisor: 121
Host: Resin OS 2.3.0+rev1

from dasshio.

JesseWebDotCom avatar JesseWebDotCom commented on July 23, 2024

broken again for me (HassOS VMDK 1.8, HA 0.74.2, supervisor 121) :(

from dasshio.

balloob avatar balloob commented on July 23, 2024

For the note about the user system, if you communicate via http://hassio/homeassistant/, you don't have to worry about that, it will be handled for you.

from dasshio.

forast3r avatar forast3r commented on July 23, 2024

I have upgraded to 0.74.2
I have enabled new auth system on HA configuration.yaml
BTW others addons can handle the auth token automatically.

Sample configuration for one of my buttons:
{
"name": "button2",
"address": "xx:xx:xx:xx:xx:xx",
"domain": "automation",
"service": "trigger",
"service_data": "{"entity_id": "automation.button2"}"
}

Result:
2018-07-28 14:42:03,018 | INFO | Reading config file: /data/options.json
2018-07-28 14:42:03,020 | INFO | Starting sniffing...
2018-07-28 14:43:44,199 | INFO | button2 button pressed!
2018-07-28 14:43:44,201 | INFO | Request: http://hassio/homeassistant/api/services/automation/trigger
2018-07-28 14:43:44,228 | INFO | Status Code: 401
2018-07-28 14:43:44,228 | ERROR | Bad request
2018-07-28 14:43:44,249 | INFO | Packet captured, waiting 20s ...

Do we really have to hardcode the url and the password or is there an elegant solution?

from dasshio.

e2m32 avatar e2m32 commented on July 23, 2024

Ok, I've been playing around with this trying to get it to work. I cloned the code and setup an internal addon for testing. This is what I got so far:

I updated dasshio.py line 56:

           try:
                if "url" in button:
                    request = requests.post(url_request, json=json.loads(
                        button["body"]), headers=json.loads(button["headers"]))
                else:
                    request = requests.post(url_request, json=json.loads(
                        button["service_data"]) , headers={'X-HASSIO-KEY': os.environ.get('HASSIO_TOKEN')})

This was added:", headers={'X-HASSIO-KEY': os.environ.get('HASSIO_TOKEN')}"

I did some logger print statements and it appears to be pulling the HASSIO_TOKEN correctly (as I am getting a 32 character string that looks like a hash), but I am still getting a 401 error.

I tried adding ,"Content-Type": "application/json"} to the header, but got the same result (I expect this isn't needed since we are identifying the body data to be json already json=...). I'm obviously new to using request().

Is there anyone out there smarter than I know why this isn't working?

from dasshio.

BertrumUK avatar BertrumUK commented on July 23, 2024

Let’s hope the dev can update their code soon to save us all having to clone our own. #fingerscrossed

from dasshio.

grantalewis avatar grantalewis commented on July 23, 2024

Agreed, @BertrumUK. It'd be great if someone dropped in to say that the fix was in process. Or something. It's been more than a week.

from dasshio.

grantalewis avatar grantalewis commented on July 23, 2024

@e2m32 Sure, understandable. To tell you the truth, I wasn't aware that you were taking the lead on this. So thanks!

from dasshio.

freekeys avatar freekeys commented on July 23, 2024

Any update on this? Just got home from a 2 week holiday and all my buttons have stopped working! .....made the silly mistake of upgrading HA in the airport :/

from dasshio.

russjr08 avatar russjr08 commented on July 23, 2024

@freekeys Looks like the issue is just awaiting a PR to be accepted. In the meantime, you can try the workaround I posted earlier!

from dasshio.

wwwebrat avatar wwwebrat commented on July 23, 2024

Can confirm that it is working again. Thx @shoejosh and @danimtb

from dasshio.

freekeys avatar freekeys commented on July 23, 2024

Awesome - how to you upgrade custom addons? I can’t see an update button so just checking what I’m missing...?

from dasshio.

grantalewis avatar grantalewis commented on July 23, 2024

Up and running once again! Thanks to all --

from dasshio.

JesseWebDotCom avatar JesseWebDotCom commented on July 23, 2024

Sweet Christmas, it works! Thanks

from dasshio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.