Terneo SX thermostat to Apple HomeKit

Флоу для интеграции терморегулятора Terneo SX в Apple HomeKit

Для успешной работы требуется изменить IP адрес терморегулятора в настройках всех нод http-request

А также изменить серийный номер и токен в двух функциях в правой части флоу.

[{"id":"d5f6bb3c.4e7758","type":"http request","z":"f487c9ba.9b8da8","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"http://IP_адрес_терморегулятора/api.cgi","tls":"","persist":false,"proxy":"","authType":"","x":1150,"y":360,"wires":[[]]},{"id":"d916203b.60e69","type":"homekit-service","z":"f487c9ba.9b8da8","isParent":true,"bridge":"","parentService":"","name":"Terneo","serviceName":"Thermostat","topic":"","filter":false,"manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","characteristicProperties":"{\n    \"TargetHeatingCoolingState\": {\n        \"validValues\": [0, 1]\n    },\n    \"CurrentHeatingCoolingState\": {\n        \"validValues\": [0, 1]\n    }\n}","x":690,"y":320,"wires":[["57912b51.e8d824"],[]]},{"id":"26274056.6992e","type":"function","z":"f487c9ba.9b8da8","name":"","func":"//Записываем полученное из Homekit значение температуры уставки в переменную v\nv = String(msg.payload.TargetTemperature)\n////Создаем JSON из серийного номера терморегулятора, access-token'a полученного из облака Terneo и параметра температуры уставки и записываем его в msg.payload\nmsg.payload = {\"sn\":\"Серийный_номер_терморегулятора\",\"auth\":\"токен_полученный_из_облака\",\"par\":[[5,1,v]]};\nreturn msg;\n","outputs":1,"noerr":0,"x":970,"y":360,"wires":[["d5f6bb3c.4e7758"]]},{"id":"57912b51.e8d824","type":"switch","z":"f487c9ba.9b8da8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"hask","v":"TargetHeatingCoolingState","vt":"str"},{"t":"hask","v":"TargetTemperature","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":830,"y":320,"wires":[["4d931f37.ae735"],["26274056.6992e"]]},{"id":"bcd86d9b.1fa43","type":"http request","z":"f487c9ba.9b8da8","name":"","method":"POST","ret":"obj","paytoqs":false,"url":"http://IP_адрес_терморегулятора/api.cgi","tls":"","persist":false,"proxy":"","authType":"","x":410,"y":280,"wires":[["d63bb703.21ee48"]]},{"id":"eb9fe401.c20e98","type":"inject","z":"f487c9ba.9b8da8","name":"Запрос телеметрии","topic":"","payload":"{\"cmd\":4}","payloadType":"json","repeat":"60","crontab":"","once":true,"onceDelay":"1","x":200,"y":280,"wires":[["bcd86d9b.1fa43"]]},{"id":"d63bb703.21ee48","type":"function","z":"f487c9ba.9b8da8","name":"","func":"//Получаем текущую температуру в градусах Цельсия\nCurrent = Number(msg.payload[\"t.1\"]/16); \n//Округляем текущую температуру до 1 десятичного знака\nCurrent = Math.round(Current*10)/10      \n//Получаем температуру уставки в градусах Цельсия\nTarget = Number(msg.payload[\"t.5\"]/16);  \n//Округляем температуру уставки до 1 десятичного знака\nTarget = Math.round(Target*10)/10        \n//Приводим значения температур к виду который примет HomeKit-нода и записываем их в msg.payload\nmsg.payload = {\"CurrentTemperature\":Current,\"TargetTemperature\":Target}  //Приводим значения температур к виду который примет HomeKit-нода и записываем их в msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":280,"wires":[["d916203b.60e69"]]},{"id":"d6c07b.e4446f88","type":"http request","z":"f487c9ba.9b8da8","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"http://IP_адрес_терморегулятора/api.cgi","tls":"","persist":false,"proxy":"","authType":"","x":1150,"y":280,"wires":[[]]},{"id":"4d931f37.ae735","type":"function","z":"f487c9ba.9b8da8","name":"","func":"//Условие при котором меняем 1 на 0 и наоборот\nif (msg.payload.TargetHeatingCoolingState == 1) {  \n  msg.payload.TargetHeatingCoolingState = 0;\n} else {\n  msg.payload.TargetHeatingCoolingState = 1;\n}\n//Записываем значение в переменную v\nv = String(msg.payload.TargetHeatingCoolingState)   \n//Создаем JSON из серийного номера терморегулятора, access-token'a полученного из облака Terneo и параметра на включение/выключение и записываем его в msg.payload\nmsg.payload = {\"sn\":\"Серийный_номер_терморегулятора\",\"auth\":\"токен_полученный_из_облака\",\"par\":[[125,7,v]]};  \nreturn msg;\n","outputs":1,"noerr":0,"x":970,"y":280,"wires":[["d6c07b.e4446f88"]]},{"id":"a3ef2bdd.b1b518","type":"http request","z":"f487c9ba.9b8da8","name":"","method":"POST","ret":"obj","paytoqs":false,"url":"http://IP_адрес_терморегулятора/api.cgi","tls":"","persist":false,"proxy":"","authType":"","x":410,"y":360,"wires":[["a56a1b13.9af278"]]},{"id":"8f2508c3.237168","type":"inject","z":"f487c9ba.9b8da8","name":"Запрос параметров","topic":"","payload":"{\"cmd\":1}","payloadType":"json","repeat":"60","crontab":"","once":true,"onceDelay":"30","x":200,"y":360,"wires":[["a3ef2bdd.b1b518"]]},{"id":"a56a1b13.9af278","type":"function","z":"f487c9ba.9b8da8","name":"","func":"//Записываем значение 26-го параметра в переменную\nState = Number(msg.payload.par[26][2]);  \n//Условие при котором значение 0 меняется на значение 1 и наоборот\nif (State == 1) {   \n  State = 0;\n} else {\n  State = 1;\n}\n//Подготовка данных для передачи в HomeKit-ноду\nmsg.payload = {\"CurrentHeatingCoolingState\":State, \"TargetHeatingCoolingState\":State}  \nreturn msg;\n","outputs":1,"noerr":0,"x":550,"y":360,"wires":[["d916203b.60e69"]]},{"id":"ab501702.92d398","type":"comment","z":"f487c9ba.9b8da8","name":"Запрос данных с терморегулятора","info":"","x":180,"y":240,"wires":[]},{"id":"f303fffa.80e5b","type":"comment","z":"f487c9ba.9b8da8","name":"Преобразование температур","info":"","x":470,"y":240,"wires":[]},{"id":"fc4fa548.3c7398","type":"comment","z":"f487c9ba.9b8da8","name":"Подготовка и отправка данных на терморегулятор","info":"","x":1020,"y":240,"wires":[]},{"id":"1c7bf627.52da1a","type":"http request","z":"f487c9ba.9b8da8","name":"","method":"POST","ret":"obj","paytoqs":false,"url":"https://my.hmarex.com/api/login/","tls":"","persist":false,"proxy":"","authType":"","x":250,"y":120,"wires":[["f3b027d6.1c7c98"]]},{"id":"4c3cbca.eb0da44","type":"inject","z":"f487c9ba.9b8da8","name":"","topic":"","payload":"{\"email\":\"адрес@почты.ru\",\"password\":\"пароль\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":120,"wires":[["1c7bf627.52da1a"]]},{"id":"f3b027d6.1c7c98","type":"debug","z":"f487c9ba.9b8da8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":410,"y":120,"wires":[]},{"id":"737e4b08.a83ad4","type":"comment","z":"f487c9ba.9b8da8","name":"Получение access-token через облачное API","info":"","x":220,"y":80,"wires":[]}]

Flow Info

Created 6 months, 3 weeks ago
Updated 6 months, 2 weeks ago
Rating: not yet rated

Owner

Node Types

Core
  • comment (x4)
  • debug (x1)
  • function (x4)
  • http request (x5)
  • inject (x3)
  • switch (x1)
Other
  • homekit-service (x1)

Tags

  • terneo
  • terneo-sx
  • homekit
  • thermostat
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option