[{"id":"293ca76e.bb4f38","type":"ui_template","z":"3d4c38d8.c679f8","group":"dfad00fc.e2b86","name":"Nest","order":1,"width":"6","height":"6","format":"
\n\n\n","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":830,"y":315,"wires":[[]]},{"id":"bec0c6fd.3116b8","type":"mqtt in","z":"3d4c38d8.c679f8","name":"Read Temp DHT11","topic":"sonoff/tele/SENSOR","qos":"0","broker":"4a31cd84.72cbd4","x":150,"y":105,"wires":[["5b69274c.cdcbd8"]]},{"id":"5b69274c.cdcbd8","type":"json","z":"3d4c38d8.c679f8","name":"","property":"payload","action":"","pretty":false,"x":305,"y":105,"wires":[["155a1d57.c32543"]]},{"id":"8ed6c05f.ee25f","type":"ui_slider","z":"3d4c38d8.c679f8","name":"Slider","label":"Target Temp","group":"dfad00fc.e2b86","order":14,"width":0,"height":0,"passthru":false,"topic":"slider","min":"10","max":"30","step":1,"x":365,"y":405,"wires":[["692dc6f1.662638"]]},{"id":"7ed1b2d6.6fdc7c","type":"function","z":"3d4c38d8.c679f8","name":"Process Alexa responses","func":"if (msg.command === \"GetTemperatureReadingRequest\"){\n x =flow.get('TempTarget');\n msg.extra = {\n \"temperatureReading\": {\n \"value\": x},\n \"applianceResponseTimestamp\": new Date().toISOString()};\n msg.payload = true;\n return msg;\n}\n\nif (msg.command === \"SetTargetTemperatureRequest\"){\nif (msg.payload < 10 || msg.payload > 30) {\n var range = {\n min: 10.0,\n max: 30.0\n }\n msg.payload = false;\n msg.extra = range;\n} \nelse {\n msg.extra = {\n targetTemperature: {\n value: msg.payload\n }\n };\n msg.payload = true;\n}\nreturn msg;\n}\n\nif (msg.command === \"TurnOnRequest\"){\n msg.payload = true;\n flow.set('away', false);\n flow.set('TempTarget', 21);\n return msg;\n \n}\n\nif (msg.command === \"TurnOffRequest\"){\n msg.payload = true;\n flow.set('away', true);\n \n return msg;\n \n \n}","outputs":1,"noerr":0,"x":485,"y":615,"wires":[["f5ce638c.dc8bb"]]},{"id":"ace4aa04.d4e008","type":"function","z":"3d4c38d8.c679f8","name":"Leaf Control","func":"x = flow.get('TempAmbient');\n\nif (x > 17 && x < 23){\n flow.set('leaf', true);\n msg.payload = true;\n msg.topic = \"has_leaf\";\n return msg;\n}\n \nelse{flow.set('leaf', false);\n msg.payload = false;\n msg.topic = \"has_leaf\";\n return msg;\n}\n\n","outputs":1,"noerr":0,"x":520,"y":270,"wires":[["293ca76e.bb4f38"]]},{"id":"d4236beb.9243d8","type":"function","z":"3d4c38d8.c679f8","name":"Color ","func":"x = flow.get('TempTarget'); //target\nz = flow.get('TempAmbient'); //ambient\n\nif (z < x){\n flow.set('heatingState', \"heating\");\n flow.set('heatingSwitch', \"ON\");\n}\nif (z >= x){\n flow.set('heatingState', \"off\");\n flow.set('heatingSwitch', \"OFF\");\n}\nmsg.payload = z;\nmsg.topic = \"ambient_temperature\";\nreturn msg;","outputs":1,"noerr":0,"x":500,"y":225,"wires":[["293ca76e.bb4f38"]]},{"id":"45fd6002.8f39b","type":"mqtt out","z":"3d4c38d8.c679f8","name":"Control Sonoff","topic":"sonoff/cmnd/POWER1","qos":"","retain":"","broker":"4a31cd84.72cbd4","x":755,"y":555,"wires":[]},{"id":"ba4bb151.fd715","type":"function","z":"3d4c38d8.c679f8","name":"Control relay","func":"if (msg.command === \"TurnOffRequest\"){\n msg.payload = \"OFF\";\n return msg;\n}\n\nif (msg.command === \"TurnOnRequest\"){\n msg.payload = \"ON\";\n flow.set('TempTarget', 21);\n return msg;\n}\nif (msg.topic === \"update\"){\n msg.payload = flow.get('heatingSwitch');\n}\nreturn msg;","outputs":1,"noerr":0,"x":520,"y":555,"wires":[["45fd6002.8f39b"]]},{"id":"155a1d57.c32543","type":"smooth","z":"3d4c38d8.c679f8","name":"Average temp","property":"payload.DHT11.Temperature","action":"mean","count":"15","round":"2","mult":"single","x":470,"y":105,"wires":[["79bc5ce0.0442f4"]]},{"id":"89762fd3.ef445","type":"alexa-home","z":"3d4c38d8.c679f8","conf":"df965cf5.93857","device":"35103","acknoledge":false,"name":"","topic":"Heating","x":220,"y":615,"wires":[["7ed1b2d6.6fdc7c","ba4bb151.fd715","692dc6f1.662638"]]},{"id":"f5ce638c.dc8bb","type":"alexa-home-resp","z":"3d4c38d8.c679f8","x":775,"y":615,"wires":[]},{"id":"4c13797d.961898","type":"function","z":"3d4c38d8.c679f8","name":"colour -away override","func":"x = flow.get('away');\n\nif (x === true){\n msg.topic = \"hvac_state\";\n msg.payload = \"off\";\n return msg;\n}\n\nmsg.topic = \"hvac_state\";\nmsg.payload = flow.get('heatingState');\n\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":315,"wires":[["293ca76e.bb4f38"]]},{"id":"aefa46a2.f36038","type":"function","z":"3d4c38d8.c679f8","name":"Away Control","func":"x = flow.get('away');\n\nif (x === true){\n flow.set('heatingSwitch', \"OFF\");\n flow.set('heatingState', \"off\");\n}\n\nmsg.topic = \"away\";\nmsg.payload = flow.get('away');\nreturn msg;\n\n","outputs":1,"noerr":0,"x":520,"y":360,"wires":[["293ca76e.bb4f38"]]},{"id":"692dc6f1.662638","type":"function","z":"3d4c38d8.c679f8","name":"set temp target","func":"if (msg.topic === \"update\"){\n msg.topic = \"target_temperature\";\n msg.payload = flow.get('TempTarget');\n return msg;\n}\n\nif (msg.command === \"SetTargetTemperatureRequest\") {\n flow.set('away', false);\n msg.topic = \"target_temperature\";\n flow.set('TempTarget', msg.payload);\n \n}\n\nif (msg.topic === \"slider\") {\n flow.set('away', false);\n msg.topic = \"target_temperature\";\n flow.set('TempTarget', msg.payload);\n}\n\nif (msg.command === \"GetTemperatureReadingRequest\"){}\n\nreturn msg;","outputs":1,"noerr":0,"x":530,"y":405,"wires":[["293ca76e.bb4f38"]]},{"id":"f3aba7f.f852c58","type":"inject","z":"3d4c38d8.c679f8","name":"Refresh every 5 sec","topic":"update","payload":"upate","payloadType":"str","repeat":"5","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":225,"wires":[["4c13797d.961898","aefa46a2.f36038","692dc6f1.662638","ba4bb151.fd715","d4236beb.9243d8","ace4aa04.d4e008","b3981462.98d958"]]},{"id":"b3981462.98d958","type":"function","z":"3d4c38d8.c679f8","name":"Update slider","func":"msg.payload = flow.get('TempTarget');\nreturn msg;","outputs":1,"noerr":0,"x":220,"y":405,"wires":[["8ed6c05f.ee25f"]]},{"id":"53430ab1.c29204","type":"function","z":"3d4c38d8.c679f8","name":"test","func":"msg.ambinet = flow.get('TempAmbient');\nmsg.target = flow.get('TempTarget');\nmsg.leaf = flow.get('leaf');\nmsg.state = flow.get('heatingState');\nmsg.switch = flow.get('heatingSwitch');\nmsg.away = flow.get('away');\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":720,"wires":[["198d2d47.f28653"]]},{"id":"198d2d47.f28653","type":"debug","z":"3d4c38d8.c679f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":590,"y":720,"wires":[]},{"id":"fb78fd8b.0ca8a","type":"inject","z":"3d4c38d8.c679f8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":720,"wires":[["53430ab1.c29204"]]},{"id":"79bc5ce0.0442f4","type":"function","z":"3d4c38d8.c679f8","name":"Update the 'TempAmbient'","func":"flow.set('TempAmbient', msg.payload.DHT11.Temperature);\nreturn msg;","outputs":1,"noerr":0,"x":695,"y":105,"wires":[[]]},{"id":"e31f1fb1.091a2","type":"comment","z":"3d4c38d8.c679f8","name":"Measure DHT11 temp and update var","info":"Gets the Temp, averages last X readings \nand updates the variable for the next push","x":210,"y":60,"wires":[]},{"id":"12d4c524.ac0acb","type":"comment","z":"3d4c38d8.c679f8","name":"Update Dial ","info":"","x":130,"y":180,"wires":[]},{"id":"bca5ef19.3f92f","type":"comment","z":"3d4c38d8.c679f8","name":"Control Relay","info":"","x":520,"y":510,"wires":[]},{"id":"7cb30851.a329a8","type":"comment","z":"3d4c38d8.c679f8","name":"Alexa Responses","info":"","x":230,"y":570,"wires":[]},{"id":"8f8745c.fc8afb8","type":"comment","z":"3d4c38d8.c679f8","name":"Test the Flow Vars","info":"","x":240,"y":675,"wires":[]},{"id":"dfad00fc.e2b86","type":"ui_group","z":"","name":"Almost Like Nest but Cheaper","tab":"4447df43.a3ad4","order":2,"disp":true,"width":"6","collapse":false},{"id":"4a31cd84.72cbd4","type":"mqtt-broker","z":"","name":"","broker":"192.168.1.183","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"df965cf5.93857","type":"alexa-home-conf","z":"","username":"quintaar"},{"id":"4447df43.a3ad4","type":"ui_tab","z":"","name":"Show","icon":"dashboard"}]