hjespers / node-red-contrib-nest

Node-Red module for Nest thermostats and smoke detectors
20 stars 15 forks source link

read away state #18

Closed x140x1n closed 5 years ago

x140x1n commented 5 years ago

How can I get the current away state? I know how to change it but no clue how to read it. The away state is not listed in the output of the request node.

svwhisper commented 5 years ago

This is the function node I use to process the message produced by the Nest "structures" query. I use it to send an update to mqtt, which is looks like this (indicating "away"): HomeStatus = {"Home_State":false}

Updated to enclose code in code block. [{"id":"c2199333.e90ff8","type":"function","z":"1c062b23.f8ccdd","name":"NEST Structure Decoding","func":"// This will decode Structures message with NEST data\n// Data from NEST function is in JavaScrip format. \n\nfor (var key in msg.payload) \n{\n var Home_Status = 0;\n var tmp_msg = {payload: \"Nest House Status is now: \" + msg.payload[key].away, topic: \"NEST-Status\"};\n \n if (msg.payload[key].away == \"home\") Home_Status = true;\n if (msg.payload[key].away == \"away\") Home_Status = false;\n \n var NEST = {Home_State: Home_Status};\n var tmp_msg1 = {payload: NEST, topic: \"nest/HomeStatus\"};\n\n node.send([tmp_msg, tmp_msg1]);\n}\n\n","outputs":2,"noerr":0,"x":650,"y":440,"wires":[[],["f46b248.3186158","8515d591.c90e68","4882f4e.567f48c"]],"outputLabels":["Master Bedroom",""]}]

x140x1n commented 5 years ago

Hi, thanks for your help. In the meantime I also figured this out but forgot to close this issue, sorry about that.