|
[{"id":"5839ae0e.452f5","type":"http request","z":"e5a8dfd7.979f9","name":"Login to Hive","method":"POST","ret":"obj","url":"https://api-prod.bgchprod.info/omnia/auth/sessions","x":470,"y":220,"wires":[["594f91a4.a0ee9"]]},{"id":"809c9c17.bc751","type":"function","z":"e5a8dfd7.979f9","name":"Set Username and Password","func":"\nmsg.headers = {\n 'Content-Type' : 'application/vnd.alertme.zoo-6.1+json',\n 'Accept' : 'application/vnd.alertme.zoo-6.1+json',\n 'X-Omnia-Client' : 'Hive Web Dashboard'\n};\nmsg.payload = JSON.stringify({\n sessions: [\n { username: \"EnterYourHiveUserIDHere\",\n password: \"EnterYourHivePasswordHere\",\n caller: \"WEB\" \n }\n ] \n }\n)\n\nreturn msg;","outputs":1,"noerr":0,"x":460,"y":120,"wires":[["5839ae0e.452f5"]]},{"id":"b0d60cf1.8e60e","type":"inject","z":"e5a8dfd7.979f9","name":"start","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":70,"y":80,"wires":[["6b7b6780.885978"]]},{"id":"47cadd4.87e7c24","type":"function","z":"e5a8dfd7.979f9","name":"set Hive request headers","func":"if(msg.payload.sessions !== undefined){\n\n //save the session out to the msg so we can use it later on\n msg.this_session = msg.payload.sessions[0].id;\n\n msg.headers = {\n 'Content-Type' : 'application/vnd.alertme.zoo-6.1+json',\n 'Accept' : 'application/vnd.alertme.zoo-6.1+json',\n 'X-Omnia-Client' : 'Hive Web Dashboard',\n 'X-Omnia-Access-Token' : msg.this_session\n }\n return msg;\n}\n\nreturn null;","outputs":1,"noerr":0,"x":304,"y":289,"wires":[["c7941f64.4624e"]]},{"id":"c7941f64.4624e","type":"http request","z":"e5a8dfd7.979f9","name":"Get nodes from Hive","method":"GET","ret":"obj","url":"https://api-prod.bgchprod.info/omnia/nodes","tls":"","x":572,"y":289,"wires":[["dee54cb9.c29e8"]]},{"id":"dee54cb9.c29e8","type":"function","z":"e5a8dfd7.979f9","name":"Set Hot Water Boost","func":"\nvar hwnode = {};\n\nif(msg.payload.nodes !== undefined){\n \n var nodes = msg.payload.nodes;\n \n for (var n in nodes){\n \n var attribs = nodes[n].attributes;\n \n if(nodes[n].name==\"Receiver\"){\n if(attribs.stateHotWaterRelay !== undefined){\n hwnode = nodes[n];\n }\n }\n } \n}\n\nmsg.headers = {\n 'Content-Type' : 'application/vnd.alertme.zoo-6.1+json',\n 'Accept' : 'application/vnd.alertme.zoo-6.1+json',\n 'X-Omnia-Client' : 'Hive Web Dashboard',\n 'X-Omnia-Access-Token' : msg.this_session\n}\nmsg.url = \"https://api-prod.bgchprod.info/omnia/nodes/\"+hwnode.id;\nif (msg.action>0){\n msg.payload =\n { nodes:[{\n attributes : {\n activeHeatCoolMode: {targetValue:\"BOOST\"},\n scheduleLockDuration : {targetValue: msg.action}\n }\n }]\n };\n}else{\n msg.payload =\n { nodes:[{\n attributes : {\n activeHeatCoolMode: {targetValue:\"HEAT\"},\n activeScheduleLock : {targetValue: false}\n }\n }]\n };\n}\n\nreturn msg;\n\n","outputs":"1","noerr":0,"x":293,"y":376,"wires":[["22a00ef6.0a1722"]]},{"id":"5dcd6366.e89c7c","type":"function","z":"e5a8dfd7.979f9","name":"set Headers & URL for Logout","func":"msg.headers = {\n 'Content-Type' : 'application/vnd.alertme.zoo-6.1+json',\n 'Accept' : 'application/vnd.alertme.zoo-6.1+json',\n 'X-Omnia-Client' : 'Hive Web Dashboard',\n 'X-Omnia-Access-Token' : msg.this_session\n}\nmsg.url = \"https://api-prod.bgchprod.info/omnia/auth/sessions/\"+msg.this_session\n\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":460,"wires":[["4bfb765c.f96cd8"]]},{"id":"4bfb765c.f96cd8","type":"http request","z":"e5a8dfd7.979f9","name":"logout from Hive","method":"DELETE","ret":"txt","url":"","tls":"","x":580,"y":460,"wires":[[]]},{"id":"594f91a4.a0ee9","type":"switch","z":"e5a8dfd7.979f9","name":"Logged In?","property":"statusCode","rules":[{"t":"neq","v":"200"},{"t":"eq","v":"200"}],"checkall":"true","outputs":2,"x":649,"y":219,"wires":[["2d68f050.f355"],["47cadd4.87e7c24"]]},{"id":"e41d7b0d.7fd448","type":"twitter out","z":"e5a8dfd7.979f9","twitter":"","name":"Tweet","x":970,"y":160,"wires":[]},{"id":"2d68f050.f355","type":"function","z":"e5a8dfd7.979f9","name":"Set Twitter Name","func":"msg.payload = \"D YourTwitterName unable to login to hive status code \"+msg.statusCode;\nreturn msg;","outputs":1,"noerr":0,"x":810,"y":160,"wires":[["e41d7b0d.7fd448"]]},{"id":"22a00ef6.0a1722","type":"http request","z":"e5a8dfd7.979f9","name":"Send Hot Water Boost","method":"PUT","ret":"obj","url":"","tls":"","x":561,"y":378,"wires":[["5dcd6366.e89c7c"]]},{"id":"6b7b6780.885978","type":"function","z":"e5a8dfd7.979f9","name":"Turn On","func":"//set the number of minutes that we want the HW boost to \n//be active for. Set to 0 to turn off (see Turn Off node)\nmsg.action = 30;\nreturn msg;","outputs":1,"noerr":0,"x":220,"y":80,"wires":[["809c9c17.bc751"]]},{"id":"7c89c8c5.0c5d08","type":"inject","z":"e5a8dfd7.979f9","name":"start","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":70,"y":160,"wires":[["21b09c74.0102b4"]]},{"id":"21b09c74.0102b4","type":"function","z":"e5a8dfd7.979f9","name":"Turn Off","func":"//set the msg.action to zero to turn off the HW boost\nmsg.action = 0;\nreturn msg;","outputs":1,"noerr":0,"x":220,"y":160,"wires":[["809c9c17.bc751"]]},{"id":"7e807621.28c428","type":"comment","z":"e5a8dfd7.979f9","name":"Edit this node","info":"adding your own Hive website username and password","x":470,"y":80,"wires":[]},{"id":"f52799b7.d68fb8","type":"comment","z":"e5a8dfd7.979f9","name":"Edit these node, or remove them","info":"Either remove these nodes if you dont want to\ntweet a failed login, or add your twitter \ncredentials and set the message text ","x":870,"y":120,"wires":[]}] |
See that you are not active at present but thanks for this, it gave me an 'in' to getting some data off my Hive hub ... why to BG make it so hard ...