hardillb / node-red-alexa-home-skill-web

Apache License 2.0
45 stars 28 forks source link

Alexa Response to SetTargetTemperatureRequest not working #126

Closed salusalpha closed 2 years ago

salusalpha commented 2 years ago

Original Message

{
  "topic":"Temperatur",
  "name":"Room1 Temperatur","
   _messageId":"3582e05d-6c47-4b18-94b9-4f7a366f68d1",
  "_applianceId":"156930",
  "_confId":"56ce27d9.f797e8",
  "command":"SetTargetTemperatureRequest",
  "extraInfo":{},
  "payload":21,
  "_msgid":"e45a6d16.5eb5d"
}

Changed message and sent to "Alexa Home Response" node

{
  "topic":"Temperatur",
  "name":"Room1 Temperatur",
  "_messageId":"3582e05d-6c47-4b18-94b9-4f7a366f68d1",
  "_applianceId":"156930",
  "_confId":"56ce27d9.f797e8",
  "command":"SetTargetTemperatureRequest",
  "extraInfo":{},
  "payload":true,
  "_msgid":"e45a6d16.5eb5d",
  "extra":{
    "targetTemperature":{
      "value":21
    }
  }
}

Response of Alexa. "I dont know what went wrong".

It seems that the "Alexa Home Response" node is not working as expected

hardillb commented 2 years ago

I'm not anywhere I can test this at the moment, but it looks right at first glance.

Can you post the flow you are using to make the changes?

Are you copying the input msg.payload into the msg.extra.targetTemperature.value field?

Here is the function node I'm using in my test setup.

if (msg.payload < 10 || msg.payload > 30) {
    var range = {
        min: 10,
        max: 30
    }
    msg.payload = false;
    msg.extra = range;

} else {

    global.set("test-temp", msg.payload);

    msg.extra = {
        targetTemperature: {
            value: msg.payload
        }
    }
    msg.payload = true;
}

return msg;
salusalpha commented 2 years ago

Yes the function code I use is yours basically ->

msg.extra = {
        targetTemperature: {
            value: msg.payload
        }
    };
    msg.payload = true;
return msg;

when payload is 23.5 it makes no difference

the flow is as below

photo_2021-10-31_12-28-34

ltonini80 commented 2 years ago

I have the same problem...

hardillb commented 2 years ago

I've tested it with the setup I used when it was built and it's just responding with "I'm not sure what went wrong"

This used to work and nothing has changed in the service so the only thing is I can think is that Amazon may have changed something, in which case there is nothing I can do.

ltonini80 commented 2 years ago

I am not an expert in programming alexa skills but it could not be that Amazon no longer wants the "extra" parameter on response but something else in the json response. I found this document, could it be useful? https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-thermostatcontroller.html

hardillb commented 2 years ago

That documentation is for the new version of the API so does not apply. If Amazon have changed something that has been backwardly applied to the old version of the API it will break anything still using the old API and is a bug, they have done this a couple of times in the past and eventually fixed it. (Amazon have totally removed any links to the old API documentation as far as I can tell).

This service is based on an early version of Amazon's Smart Home device API, to move it to a new version would take a total rewrite which is just not going to happen.

But as I said in the last message, I'm now back with my test kit and tests that all worked in the past now give the error.

This project is purely in maintenance mode, where only minimal changes will be made, so at this point I'm just going to wait and see if Amazon fix the old API.

jaymemaurice commented 2 years ago

@hardillb actually fixed this in #12 I think the documentation was not updated. try:

    msg.extra = {
        targetTemperature: {
            value: msg.payload // or whatever value
        },
        applianceResponseTimestamp: new Date().toISOString(),
        temperatureMode: {
            value: "AUTO"
        }
    };
877dev commented 1 year ago

@hardillb actually fixed this in #12 I think the documentation was not updated. try:

    msg.extra = {
        targetTemperature: {
            value: msg.payload // or whatever value
        },
        applianceResponseTimestamp: new Date().toISOString(),
        temperatureMode: {
            value: "AUTO"
        }
    };

Worked for me also, thanks!