maddox / dasher

🔘 A simple way to bridge your Amazon Dash buttons to HTTP services
MIT License
710 stars 93 forks source link

HTTP Requests not working. Getting response undefined error #70

Open howdyneighbor opened 7 years ago

howdyneighbor commented 7 years ago

I can't figure out what the issue is here. I followed /u/bruhautomation tutorial to get Dasher up and running.

When I use the IFTTT method, it works perfectly (granted, with an expected delay). When I try to use the HTTP request method to shorten the delay, nothing happens. Here is the code I am using:

{"buttons":[
  {
    "name": "Gatorade",
    "address": "ADDRESS",
    "url": "https://NAME.duckdns.org/api/services/scene/turn_on",
    "method": "POST",
    "headers": {"x-ha-access": "PASSWORD"},
    "json": true,
    "body": {"entity_id": "scene.morning"}
  }
]}

Im using the exact same information with another app that sends HTTP requests and it works perfectly, so Im not sure what the issue is here. Ive tried a variety of combinations of the above code as well, including appending the port number (which shouldnt be necesary for DNS) and changing x-ha-access to authorization, as I saw you have that in your example but it all results in the same errors.

This is the terminal readout when I try to run everything:

pi@hassbian:~/dasher $ sudo npm run start

> dasher@1.3.0 start /home/pi/dasher
> node app.js

[2017-04-06T13:04:19.030Z] Gatorade added.
[2017-04-06T13:04:28.974Z] Gatorade pressed. Count: 1
[2017-04-06T13:06:36.562Z] there was an error
[2017-04-06T13:06:36.562Z] Response undefined
[2017-04-06T13:07:23.418Z] there was an error
[2017-04-06T13:07:23.418Z] Response undefined
howdyneighbor commented 7 years ago

It seems to be an issue with my SSL certificate. Using this curl command using insecure mode works:

curl -k -X POST -H "x-ha-access: X" \
-H "Content-Type: application/json" \
-d '{"entity_id": "scene.morning"}' \
https://localhost:8123/api/services/scene/turn_on

Yet using this

{"buttons":[
  {
    "name": "Gatorade",
    "address": "X",
    "url": "https://localhost:8123/api/services/scene/turn_on",
    "insecure": true,
    "method": "POST",
    "headers": {"x-ha-access": "X"},
    "json": true,
    "body": {"entity_id": "scene.morning"}
  }
]}

Results in the same error.