Apollon77 / alexa-remote

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setTargetTemperature

skillix opened this issue · comments

hello, we are using alexa-remote for jeedom with https://github.com/sigalou/jeedom_alexaapi/tree/beta/resources in alexaapi.js

We have been trying to change thermostat settings for a long time.

I'm approaching the goal, but I think I'm missing a detail:

if (parameters.action == "setTargetTemperature") {

        parameters.targetSetpoint={"value": req.query.targetSetpoint,"scale": "CELSIUS"};
      
		toReturn.push({'deviceId': req.query.device, 'action': parameters.action, 'targetSetpoint': parameters.targetSetpoint});
	}

and I get in return:

5/6/2021, 7:28:33 AM][] : {API}    ╔═══════[Lancement /SmarthomeCommand avec paramètres -> device: d328484e-656b-432d-a409-4a90c4d1de60 & command: setTargetTemperature
[5/6/2021, 7:28:33 AM][DEBUG] : {Remote} ║ Sending Request with {"host":"alexa.amazon.fr","path":"/api/phoenix/state","method":"PUT","timeout":10000,"headers":{}} and data={"controlRequests":[{"entityId":"d328484e-656b-432d-a409-4a90c4d1de60","parameters":{"action":"setTargetTemperature","targetSetpoint":{"value":19.5,"scale":"CELSIUS"}}}]}
[5/6/2021, 7:28:33 AM][DEBUG] : {Remote} ║ Réponse: {"controlResponses":[],"errors":[{"entity":{"entityId":"d328484e-656b-432d-a409-4a90c4d1de60","entityType":null},"code":"FAILURE_TO_SEND","message":"Validation failed with the following error(s): [InvalidParameters: [TemperatureParameter(value=19.5, scale=CELSIUS)] for action setTargetTemperature]","data":null}]}

I think you have already encountered this problem and I hope you have a solution

Honestly, I also have that issue open in the ioBroker world :-(

Reason: I do not have a Thermostat where I can change the temperature :-(

If you have one:
Todo is in fact to use Proxy like Charles and grab the request that the Alexa App is doing when you change that via app (is it possible at all to do that via the Alexa App?)

DO you have the chance to get such a Charles File? I can guide you and check it afterwards

yes I have a thermostat in alexa, normally it is not compatible, but with jeedom it is possible to create virtual objects and send them to alexa, then it is possible to test everything.

I'm ready to try everything, I have already tried to snort my phone, but obviously google has set up some protection.

I also think I am very far away.

I looked at lots of different code like where http://nasfamilyone.synology.me/tuto&co/tutoriels/tuto-sonoff/code/thermostat_sonoff_alexa.ino.html and https://github.com/kakopappa/sinric/blob/master/arduino_examples/thermostat_example.ino
obviously there is a common frame :

/ Example payloads For Thermostat
// {"deviceId": xxxx, "action": "setPowerState", value: "ON"} // https://developer.amazon.com/docs/device-apis/alexa-thermostatcontroller.html
// {"deviceId": xxxx, "action": "SetTargetTemperature", value: "targetSetpoint": { "value": 20.0, "scale": "CELSIUS"}} // https://developer.amazon.com/docs/device-apis/alexa-thermostatcontroller.html#settargettemperature
// {"deviceId": xxxx, "action": "AdjustTargetTemperature", value: "targetSetpointDelta": { "value": 2.0, "scale": "FAHRENHEIT" }} // https://developer.amazon.com/docs/device-apis/alexa-thermostatcontroller.html#adjusttargettemperature

I am close to the example frame, but not close enough

5/7/2021, 5:41:12 AM][DEBUG] : {MAX}[{"entityId":"xxxx","parameters":{"action":"setTargetTemperature","targetSetpoint":{"value":20,"scale":"CELSIUS"}}}]

Ok for the debugging:

When it works you can open a webpage or app and internet works AND see requests in charles that are NOT "CONNECT" only (if you only see CONNECT then SSL Proxying oin charles is off.
If that works and you see requests with request data and resposne open the alexa app and go to the device page and such.

Then change the temperature and you should see the request. if you like just post that infos or cleanup the charles file and send me the chls file (save charles session) via email to iobroker@fischer-ka.de

I succeeded !!!!!!!! your snorting method was a bit too complex for me, but I managed to install "Packet capture" on a fire tablet with an android old, no root required.

{"action":"setTargetTemperature","targetTemperature.value":"20.0","targetTemperature.scale":"celsius"}}

I continue tomorrow for the other thermostat commands

aahhh so they do not want an object but two separate values ?! interesting. Tell your progress or better do a PR :-))

I will also try to see if I can mute, now that I understand what I am doing (almost 20 years since I stopped developing)

All good ...any clue is great that I can take a look too.

parameters={'action': 'setThermostatMode',"thermostatMode.value":req.query.thermostatMode};

req.query.thermostatMode ==> auto, cool, heat or off

I did not find how to change the thermostat mode in alexa apply or routine, but with the request it works, which confirms that we may request something not available in the application so I resume my search for the mute; )

@skillix do you also know the Right stuff for upper/lowerTemperature points?

I had not found it, and I did not push the investigation, because in the end it is easily achievable by modifying the instruction with a scenario or script

Ok, we in fact identified it ...
51affd2e-5138-428b-8924-12610865a63a

and you always need to send both!!

I close because now we know all cases for the ThermostatController