[ { "id": "79851696.39fbb", "type": "http request", "z": "dae944a5.4af0b8", "name": "", "method": "POST", "ret": "obj", "paytoqs": false, "url": "https://api.sst-cloud.com/auth/login/", "tls": "", "proxy": "", "authType": "basic", "x": 810, "y": 360, "wires": [ [ "455040f6.dd4a08" ] ] }, { "id": "9a908b5f.552008", "type": "inject", "z": "dae944a5.4af0b8", "name": "", "topic": "", "payload": "", "payloadType": "date", "repeat": "10", "crontab": "", "once": true, "onceDelay": "20", "x": 270, "y": 380, "wires": [ [ "27aeb0fa.2b93e8" ] ] }, { "id": "40d41bbb.20e7ac", "type": "function", "z": "dae944a5.4af0b8", "name": "getting session id", "func": "msg.headers = {};\nmsg.headers[\"content-type\"] = 'application/x-www-form-urlencoded';\nreturn msg;", "outputs": 1, "noerr": 0, "x": 630, "y": 360, "wires": [ [ "79851696.39fbb" ] ] }, { "id": "6a49cfa8.ef237", "type": "http request", "z": "dae944a5.4af0b8", "name": "", "method": "GET", "ret": "obj", "paytoqs": false, "url": "https://api.sst-cloud.com/houses", "tls": "", "proxy": "", "authType": "basic", "x": 1170, "y": 360, "wires": [ [ "8154d694.0cbdd8" ] ] }, { "id": "455040f6.dd4a08", "type": "function", "z": "dae944a5.4af0b8", "name": "getting the house", "func": "var characteristic = {}\n\nflow.set('key',msg.payload.key)\ncharacteristic = flow.get('key')\n\n//msg.payload = characteristic\nmsg.headers = {};\nmsg.headers[\"content-type\"] = 'application/x-www-form-urlencoded';\nmsg.headers[\"Authorization\"] = \"Token \" + characteristic\nreturn msg;", "outputs": 1, "noerr": 0, "x": 990, "y": 360, "wires": [ [ "6a49cfa8.ef237" ] ] }, { "id": "cc3929c0.e0075", "type": "http request", "z": "dae944a5.4af0b8", "name": "", "method": "GET", "ret": "obj", "paytoqs": false, "url": "https://api.sst-cloud.com/houses/{{payload.house}}/devices/", "tls": "", "proxy": "", "authType": "basic", "x": 650, "y": 420, "wires": [ [ "3e714a8a.0c65ee" ] ] }, { "id": "8154d694.0cbdd8", "type": "function", "z": "dae944a5.4af0b8", "name": "getting the data", "func": "var characteristic = {}\n\nflow.set('house',msg.payload[0].id)\ncharacteristic.house = flow.get('house')\n\nmsg.payload = characteristic\nmsg.headers = {};\nmsg.headers[\"content-type\"] = 'application/x-www-form-urlencoded';\nmsg.headers[\"Authorization\"] = \"Token \" + flow.get('key');\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 480, "y": 420, "wires": [ [ "cc3929c0.e0075" ] ] }, { "id": "969ca559.8e6a88", "type": "function", "z": "dae944a5.4af0b8", "name": "Water Counts", "func": "var msg1 = {};\nvar msg2 = {};\n\nvar characteristic1 = {};\nvar characteristic2 = {};\n\n \n\n\ncharacteristic1.CurrentAmbientLightLevel = parseFloat(msg.payload[0].value/1000);\ncharacteristic2.CurrentAmbientLightLevel = parseFloat(msg.payload[1].value/1000);\n\nmsg1.payload = characteristic1\nmsg2.payload = characteristic2\n\nreturn [msg1,msg2]; ", "outputs": 2, "noerr": 0, "x": 1200, "y": 620, "wires": [ [], [] ] }, { "id": "3c404325.1a070c", "type": "http request", "z": "dae944a5.4af0b8", "name": "", "method": "GET", "ret": "obj", "paytoqs": false, "url": "https://api.sst-cloud.com/houses/{{payload.house}}/devices/{{payload.deviceIdSensors}}/counters/", "tls": "", "proxy": "", "authType": "basic", "x": 1030, "y": 620, "wires": [ [ "969ca559.8e6a88" ] ] }, { "id": "6eaca9f2.e609a8", "type": "function", "z": "dae944a5.4af0b8", "name": "", "func": "var TargetHeatingCoolingState = flow.get('TargetHeatingCoolingState')||0\n\nif(msg.payload.TargetHeatingCoolingState !== undefined){\n TargetHeatingCoolingState = msg.payload.TargetHeatingCoolingState;\n flow.set('TargetHeatingCoolingState', msg.payload.TargetHeatingCoolingState)\n}\n\nvar characteristic = {}\nvar msg1 = {}\nvar msg2 = {}\nvar msg3 = {}\nvar msg4 = {}\n\nif (msg.payload.TargetTemperature) {\n if (TargetHeatingCoolingState === 1) {\n msg1.payload = {\"temperature_manual\": parseInt(msg.payload.TargetTemperature)}\n msg1.payload.house = flow.get('house')\n msg1.payload.deviceIdThermo = flow.get('deviceIdThermo')\n msg1.headers = {};\n msg1.headers[\"content-type\"] = 'application/x-www-form-urlencoded';\n msg1.headers[\"Authorization\"] = \"Token \" + flow.get('key');\n }\n else {\n if (flow.get('ThermoMode') === 'coolModeActivated') {\n msg4.payload = {\"chart_temperature_economical\": parseInt(msg.payload.TargetTemperature)}\n }\n else if (flow.get('ThermoMode') === 'heatModeActivated') {\n msg4.payload = {\"chart_temperature_comfort\": parseInt(msg.payload.TargetTemperature)}\n } \n msg4.payload.house = flow.get('house')\n msg4.payload.deviceIdThermo = flow.get('deviceIdThermo')\n msg4.method = \"PATCH\"\n msg4.headers = {};\n msg4.headers[\"content-type\"] = 'application/x-www-form-urlencoded';\n msg4.headers[\"Authorization\"] = \"Token \" + flow.get('key'); \n }\n\n}\nelse if (!msg.payload.TargetTemperature) {\n if (TargetHeatingCoolingState === 1) {\n msg2.payload = {\"status\": \"on\"}\n msg3.payload = {\"mode\": \"manual\"} \n }\n else if (TargetHeatingCoolingState === 3) {\n msg2.payload = {\"status\": \"on\"}\n msg3.payload = {\"mode\": \"chart\"} \n }\n else {\n msg2.payload = {\"status\": \"off\"}\n } \n msg2.payload.house = flow.get('house')\n msg2.payload.deviceIdThermo = flow.get('deviceIdThermo')\n msg2.headers = {};\n msg2.headers[\"content-type\"] = 'application/x-www-form-urlencoded';\n msg2.headers[\"Authorization\"] = \"Token \" + flow.get('key');\n msg3.payload.house = flow.get('house')\n msg3.payload.deviceIdThermo = flow.get('deviceIdThermo')\n msg3.headers = {};\n msg3.headers[\"content-type\"] = 'application/x-www-form-urlencoded';\n msg3.headers[\"Authorization\"] = \"Token \" + flow.get('key');\n}\n\nreturn [msg1, msg2, msg3, msg4]\n\n\n", "outputs": 4, "noerr": 0, "x": 670, "y": 220, "wires": [ [ "17acf6c6.fce391" ], [ "e0fbc631.f5a7b8" ], [ "ab6cebc3.b0ea68" ], [ "51b44786.5ec9c" ] ] }, { "id": "523626a8.bfee", "type": "switch", "z": "dae944a5.4af0b8", "name": "hap.context", "property": "hap.context", "propertyType": "msg", "rules": [ { "t": "nnull" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 530, "y": 220, "wires": [ [ "6eaca9f2.e609a8" ] ] }, { "id": "ebf4afde.fcb46", "type": "http request", "z": "dae944a5.4af0b8", "name": "status", "method": "POST", "ret": "txt", "url": "http://api.sst-cloud.com/houses/{{payload.house}}/devices/{{payload.deviceIdThermo}}/status/", "tls": "", "x": 950, "y": 200, "wires": [ [] ] }, { "id": "835cde15.dafc38", "type": "http request", "z": "dae944a5.4af0b8", "name": "temperature", "method": "POST", "ret": "txt", "url": "http://api.sst-cloud.com/houses/{{payload.house}}/devices/{{payload.deviceIdThermo}}/temperature/", "tls": "", "x": 970, "y": 160, "wires": [ [] ] }, { "id": "17acf6c6.fce391", "type": "switch", "z": "dae944a5.4af0b8", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "nempty" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 830, "y": 160, "wires": [ [ "835cde15.dafc38" ] ] }, { "id": "e0fbc631.f5a7b8", "type": "switch", "z": "dae944a5.4af0b8", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "nempty" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 830, "y": 200, "wires": [ [ "ebf4afde.fcb46" ] ] }, { "id": "25ce561d.cec01a", "type": "http request", "z": "dae944a5.4af0b8", "name": "mode", "method": "POST", "ret": "txt", "url": "http://api.sst-cloud.com/houses/{{payload.house}}/devices/{{payload.deviceIdThermo}}/mode/", "tls": "", "x": 950, "y": 240, "wires": [ [ "a0808a34.6290b" ] ] }, { "id": "ab6cebc3.b0ea68", "type": "switch", "z": "dae944a5.4af0b8", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "nempty" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 830, "y": 240, "wires": [ [ "25ce561d.cec01a" ] ] }, { "id": "d2f4d295.94ed58", "type": "http request", "z": "dae944a5.4af0b8", "name": "patch temp", "method": "use", "ret": "txt", "url": "http://api.sst-cloud.com/houses/{{payload.house}}/devices/{{payload.deviceIdThermo}}/", "tls": "", "x": 970, "y": 280, "wires": [ [] ] }, { "id": "51b44786.5ec9c", "type": "switch", "z": "dae944a5.4af0b8", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "nempty" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 830, "y": 280, "wires": [ [ "d2f4d295.94ed58" ] ] }, { "id": "27aeb0fa.2b93e8", "type": "template", "z": "dae944a5.4af0b8", "name": "", "field": "payload", "fieldType": "msg", "format": "json", "syntax": "plain", "template": "{\n \"username\": \"test@gmail.com\",\n \"password\": \"123123123\",\n \"email\": \"test@gmail.com\",\n \"language\": \"ru\"\n}", "output": "json", "x": 460, "y": 360, "wires": [ [ "40d41bbb.20e7ac" ] ] }, { "id": "f2cd9b13.a0424", "type": "link in", "z": "dae944a5.4af0b8", "name": "", "links": [ "fe1fa030.eac8d8", "b9847fdb.37a9a" ], "x": 255, "y": 220, "wires": [ [] ] }, { "id": "a0808a34.6290b", "type": "function", "z": "dae944a5.4af0b8", "name": "set justTemp to 1", "func": "flow.set(\"justTemp\", 1);\nreturn msg", "outputs": 1, "noerr": 0, "x": 1150, "y": 240, "wires": [ [ "ff6506b0.8bc048" ] ] }, { "id": "1ad08973.2b5b67", "type": "function", "z": "dae944a5.4af0b8", "name": "set justTemp to 0", "func": "flow.set(\"justTemp\", 0);", "outputs": 1, "noerr": 0, "x": 1401, "y": 360, "wires": [ [] ] }, { "id": "5a0b1b4c.2df134", "type": "link in", "z": "dae944a5.4af0b8", "name": "", "links": [ "ff6506b0.8bc048" ], "x": 315, "y": 340, "wires": [ [ "27aeb0fa.2b93e8" ] ] }, { "id": "ff6506b0.8bc048", "type": "link out", "z": "dae944a5.4af0b8", "name": "", "links": [ "5a0b1b4c.2df134" ], "x": 1275, "y": 240, "wires": [] }, { "id": "3e714a8a.0c65ee", "type": "function", "z": "dae944a5.4af0b8", "name": "getting the data", "func": "var characteristic = {}\ncharacteristic.Sensors = {}\ncharacteristic.Thermo = {}\n\n\nfor (i=0; i currentDate) {\n currentMode[i] = true\n }\n else {\n currentMode[i] = false\n }\n }\n}\nelse {\n for (i=0; i currentDate) {\n currentMode[i] = true\n }\n else {\n currentMode[i] = false\n }\n }\n}\n\nfor (i=0; i