Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discovery works, status works, but setting the temp doesnt? #29

Open
eelstretching opened this issue Dec 28, 2018 · 3 comments
Open

Discovery works, status works, but setting the temp doesnt? #29

eelstretching opened this issue Dec 28, 2018 · 3 comments

Comments

@eelstretching
Copy link

eelstretching commented Dec 28, 2018

Thanks for this repo, Kate! Getting Alexa to set the temp for me is my fun Christmas week activity.

I followed the instructions on the wiki and wung (winged?) it a little bit when the AWS setup seemed different than what was in the wiki (can one do a PR for a Wiki in github?).

I can add the skill to my Alexa from the dev skills and the device shows the correct temp from the thermostat when I use the Alexa app on my phone (and even tracks changes that I make on the thermostat itself!), but when I use Alexa to try to set the temperature, it fails. The Alexa hardware just tells me that it can't do that and the Alexa app on my phone puts up a "Device is unresponsive" message.

I set DEBUG to 1 in the env of the Lambda function, and looking through the CloudWatch logs I see the following:

2018-12-28T01:49:55.192Z	dfa1250f-0a42-11e9-b4b8-b1c8dd980680	Event from Alexa:
{
    "directive": {
        "header": {
            "namespace": "Alexa.ThermostatController",
            "name": "SetTargetTemperature",
            "payloadVersion": "3",
            "messageId": "1d19594f-22dc-4cb0-b78b-29e918f1dfc5",
            "correlationToken": "AAAAAAAAAACjrEywlmOLS6i83L9T3/4LDAIAAAAAAADfjzpZeD+ubB4uS/cK/ZNBWObld2k16LRXZimbsb+wtsEDywc+b8g0s7C5XjxP+af8YOoTuXJpxx09XA7NBHg+5Hp2QOceec89pZCtO4J2cy8T9nQPNeRNOpu9gZdJp2+LUanWiRS/oavGOzUDDCWeArX9cd7hihdomaibW/7t+Qch2Gxqm6goau4xI93F6C0lwa0zLtRu8jt/B8BqMoz9knVJdpUkszWv5gEHxYhw7iDUKnJzaNM0GNw1104qx1QQO8TqrWlA37U5JfhsFco2OlnE/GKR99tATkCmX/nUWYZip+uMXA1DaRtpTe+Hof614X8niEHPQtsYRHl5GVi8P3qcO7ZDbPqOlkx+iecbQIYZyPl0UlDxaYPTaq6gzoNnN+22CR5sf4V4jLddDCCMDTNcW+IdG3xfOV170pZAsr5isEM+wb8Qu6XGi5wZ/YudRjfS9orkUXJNwD+PZxrFP2OoHcTrm8Kecrj4aD4feQsYaELJeOxyE3JvpbhXXUQGdfIbtR0BaL9LCtMYYgBmGpeh+WjcmOfRf/YtX1IdJnipDzlC4Q5Dn+XVemmx0/oD8NJ1yzWl5MZ12JtuLkvbS4rCjBBPACEMPWac24MdaY64aI8kNMH+yos3Y8/4RROQi2owKGesECYjAZe7qcVN7jv7x8Edfq/Epcl1zyBnLPS9V7KumOJ/rlWvDA=="
        },
        "endpoint": {
            "scope": {
                "type": "BearerToken",
                "token": "AnythingCanBeAToken"
            },
            "endpointId": "WS15G05225",
            "cookie": {}
        },
        "payload": {
            "lowerSetpoint": {
                "value": 70,
                "scale": "FAHRENHEIT"
            },
            "upperSetpoint": {
                "value": 75,
                "scale": "FAHRENHEIT"
            }
        }
    }
}

which looks like the request to set the temp to 70 made it through to the Lambda function, but then the next part of this request is the following:

2018-12-28T01:49:55.973Z	dfa1250f-0a42-11e9-b4b8-b1c8dd980680	[TypeError: Cannot read property 'value' of undefined]

which looks like some Javascript tried to look up a property called value in an undefined value. I don't have a whole lot of Javascript experience, but poking around in the main index.js didn't uncover anything obvious, so I'm thinking it might be in the icomfort js?

Any suggestions would be greatly appreciated!

@kate-hall
Copy link
Owner

Thanks for this, @eelstretching! I upgraded the underlying icomfort-js dependency. I also updated the wiki, but it looks like you figured it out just fine!

Try adding a new zip of the src folder contents to your Lambda function. Let me know if the issue isn't resolved?

@eelstretching
Copy link
Author

eelstretching commented Dec 30, 2018

Thanks for the update, but unfortunately, it looks like it didn't work (Dang! :-) I tried both pulling the changes from the git repo on the master branch and from the zip file. I then deleted the thermostat device from the Alexa app and disabled the Skill and then re-discovered it as described on the update wiki page.

As I'm still doing all of this with only a vague understanding of the pieces (Javascript only runs in browsers, right? :-), I modified the log message for the Alexa event to make sure that I was running the new code that I'd uploaded.

It looks like the new code is running in the Lambda and it gets a TypeError when I try to change the temp from the Alexa app on my phone. At best I get "Your device doesn't seem to support that" from my Alexa hardware and at worst the Alexa hardware claims to not know about the device. Their device naming and how you use it in the sentences seems kind of bad? Maybe it's just me. I haven't figured out a non-awkward name for the thermostat yet.

What else can I do to help debug this? Is it possible to get a full stack trace out of the node.js stack so we can see where the TypeError is coming from?

Edit to add: wrapping the exports.handler in a try/catch didn't help.

@kate-hall
Copy link
Owner

The naming is awkward. I've named mine "Home" and "Thermostat," so I can say "Alexa, set Thermostat to 74 degrees."

Some troubleshooting guesses: you're zipping and uploading the /src folder contents only, yes? Not the enclosing folder too?

I'm attaching a screenshot of the resulting Lambda structure in AWS:
screen shot 2018-12-30 at 5 15 18 pm

Next up, if the above is right and you've run through the configuration on both the Developer and AWS portal sides with the new wiki instructions to make sure your authentication endpoints are set up correctly and you're using the right version of Node (8.10 now).

Configure a test event in the dropdown next to the "Test" button in the above screenshot, in AWS. Yours should have the following contents:

{
  "directive": {
    "header": {
      "namespace": "Alexa.ThermostatController",
      "name": "SetTargetTemperature",
      "payloadVersion": "3",
      "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
      "correlationToken": "dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg=="
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "access-token-from-skill"
      },
      "endpointId": "WS15G05225",
      "cookie": {}
    },
    "payload": {
      "targetSetpoint": {
        "value": 73,
        "scale": "FAHRENHEIT"
      },
      "lowerSetpoint": {
        "value": 73,
        "scale": "FAHRENHEIT"
      },
      "upperSetpoint": {
        "value": 76,
        "scale": "FAHRENHEIT"
      }
    }
  }
}

Save it, and run it by clicking the Test button with that test selected in the dropdown. You should see a response below the code, please copy and paste it back.

Note: if the above is succesful, you should see your temperature change on your thermostat! The above test event includes your thermostat's ID (which you pasted in earlier).

Another thought: when I updated this yesterday, Alexa didn't immediately recognize my thermostat. I did a quick search and there were some outages...they had a big one right at Christmastime (for potentially obvious reasons) but an hour later, she was able to change it via voice. I STILL get a "device unresponsive" in the Alexa app when I attempt to change it through the UI. Alexa's thermostat UI in the app has been buggy at best, I've contacted them once earlier this year about a bug and it took forever to fix. I'm looking into whether the app UI issue is mine or theirs, but I have a feeling it's on their end. However, using voice works well for me at the moment, so the above test event should also work for you.

Interested to see the response from your end!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants