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

A Node-RED node to control things via Amazon Alexa
https://alexa-node-red.bm.hardill.me.uk/
Apache License 2.0
89 stars 42 forks source link

GetTemperatureReadingRequest #52

Closed bolfox closed 5 years ago

bolfox commented 5 years ago

Hi,

i'm using the skill with my knx system, i'am able to set a thermostat value.

I can't understand how to read the ambient temperature and have a voice reply from alexa.

I have made this flow but how to link to node Response?

[{"id":"9851ac97.d7b53","type":"alexa-home","z":"cebd3f06.b57ad","conf":"dc3ca09a.9058f","device":"41840","acknoledge":false,"name":"Cucina","topic":"","x":110,"y":480,"wires":[["c96c1232.e4b4c"]]},{"id":"a1125e03.e63a","type":"debug","z":"cebd3f06.b57ad","name":"GET","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":510,"y":380,"wires":[]},{"id":"62c2ad40.3416a4","type":"alexa-home-resp","z":"cebd3f06.b57ad","x":1040,"y":460,"wires":[]},{"id":"c96c1232.e4b4c","type":"switch","z":"cebd3f06.b57ad","name":"","property":"command","propertyType":"msg","rules":[{"t":"eq","v":"GetTemperatureReadingRequest","vt":"str"},{"t":"eq","v":"SetTargetTemperatureRequest","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":330,"y":480,"wires":[["a1125e03.e63a","b6f18497.8c0688"],["2486fa28.71b366"]]},{"id":"2486fa28.71b366","type":"debug","z":"cebd3f06.b57ad","name":"SET","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":510,"y":580,"wires":[]},{"id":"e624b6f5.83a2a8","type":"knx-device","z":"cebd3f06.b57ad","controller":"60cc37.431e13c8","mode":"manual","groupaddresses":"","name":"T Cucina","groupaddress":"1/4/53","statusga":"","dpt":"DPT9","x":660,"y":460,"wires":[["455d0453.38c9dc"]]},{"id":"755f67d8.fb3168","type":"debug","z":"cebd3f06.b57ad","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":990,"y":420,"wires":[]},{"id":"ca32a25d.3cd68","type":"inject","z":"cebd3f06.b57ad","name":"","topic":"read","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":510,"y":500,"wires":[["e624b6f5.83a2a8"]]},{"id":"b6f18497.8c0688","type":"function","z":"cebd3f06.b57ad","name":"","func":"msg.topic = \"read\"\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":460,"wires":[["e624b6f5.83a2a8"]]},{"id":"455d0453.38c9dc","type":"function","z":"cebd3f06.b57ad","name":"","func":"msg.extra = {\n \"temperatureReading\": {\n \"value\": 30\n },\n \"applianceResponseTimestamp\": new Date().toISOString()\n};\nmsg.payload = true;\nreturn msg; ","outputs":1,"noerr":0,"x":810,"y":460,"wires":[[]]},{"id":"dc3ca09a.9058f","type":"alexa-home-conf","z":"","username":"xxx"},{"id":"60cc37.431e13c8","type":"knx-controller","z":"","ipAddr":"192.168.0.99","ipPort":"3671","physAddr":"15.15.15"}]

hardillb commented 5 years ago

You need to wire the function node to the Alexa Response node

hardillb commented 5 years ago

Actually looking at the code for the knx-device node it does not pass the incoming message through. This is why it doesn't work, because the response node needs to be passed the original message that arrived from the Alexa in node.

The knx node should be passing incoming messages on, you should raise an issue against that node to get it fixed.

hardillb commented 5 years ago

There is already an open issue for this:

https://bitbucket.org/ekarak/node-red-contrib-knxjs/issues/27/pass-through-msg-object-in-knx-device-node

bolfox commented 5 years ago

Tnx hardbill...

Using a join node can be a solution?

Which message i need to change and send back to the response node?

hardillb commented 5 years ago

No, the solution is to fix the knx-device node to pass the original message through

bolfox commented 5 years ago

Found a solution usign the change nodes and passing the value to alexa... [{"id":"5e8d6d9.12f3094","type":"tab","label":"Alexa T","disabled":false,"info":""},{"id":"d8f4cf30.76a9b","type":"debug","z":"5e8d6d9.12f3094","name":"GET","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":430,"y":160,"wires":[]},{"id":"288dbcee.114384","type":"switch","z":"5e8d6d9.12f3094","name":"","property":"command","propertyType":"msg","rules":[{"t":"eq","v":"GetTemperatureReadingRequest","vt":"str"},{"t":"eq","v":"SetTargetTemperatureRequest","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":230,"y":280,"wires":[["d8f4cf30.76a9b","a16bec4f.c36cc","1d9005ff.f3cafa"],["e5ffe337.9762e"]]},{"id":"e5ffe337.9762e","type":"debug","z":"5e8d6d9.12f3094","name":"SET","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":430,"y":360,"wires":[]},{"id":"7d256689.d3d1e8","type":"knx-device","z":"5e8d6d9.12f3094","controller":"60cc37.431e13c8","mode":"manual","groupaddresses":"","name":"T","groupaddress":"1/4/53","statusga":"","dpt":"DPT9","x":570,"y":200,"wires":[["5546d7a5.b50b38"]]},{"id":"85a15693.bb2cc8","type":"inject","z":"5e8d6d9.12f3094","name":"","topic":"read","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":430,"y":240,"wires":[["7d256689.d3d1e8"]]},{"id":"a16bec4f.c36cc","type":"function","z":"5e8d6d9.12f3094","name":"","func":"msg.topic = \"read\"\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":200,"wires":[["7d256689.d3d1e8"]]},{"id":"1d9005ff.f3cafa","type":"function","z":"5e8d6d9.12f3094","name":"","func":"msg.extra = {\n \"temperatureReading\": {\n \"value\": 99\n },\n \"applianceResponseTimestamp\": new Date().toISOString()\n};\nmsg.payload = true;\nreturn msg; ","outputs":1,"noerr":0,"x":570,"y":280,"wires":[["ba45e8db.8e6f58"]]},{"id":"12b7395e.d66bc7","type":"alexa-home","z":"5e8d6d9.12f3094","conf":"dc3ca09a.9058f","device":"41840","acknoledge":false,"name":"Cucina","topic":"","x":70,"y":280,"wires":[["288dbcee.114384"]]},{"id":"f0526e1a.f8265","type":"alexa-home-resp","z":"5e8d6d9.12f3094","x":980,"y":280,"wires":[]},{"id":"ba45e8db.8e6f58","type":"change","z":"5e8d6d9.12f3094","name":"","rules":[{"t":"set","p":"extra.temperatureReading.value","pt":"msg","to":"temp","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":360,"wires":[["f0526e1a.f8265"]],"inputLabels":["2"],"outputLabels":["1"]},{"id":"5546d7a5.b50b38","type":"change","z":"5e8d6d9.12f3094","name":"","rules":[{"t":"set","p":"temp","pt":"flow","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":220,"wires":[[]]},{"id":"60cc37.431e13c8","type":"knx-controller","z":"","ipAddr":"192.168.0.99","ipPort":"3671","physAddr":"15.15.15"},{"id":"dc3ca09a.9058f","type":"alexa-home-conf","z":"","username":"xxx"}]