Advertisement
Guest User

Untitled

a guest
Sep 17th, 2022
593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 66.38 KB | None | 0 0
  1. [
  2. {
  3. "id": "6d2f931c87bbb1a0",
  4. "type": "tab",
  5. "label": "Daikin Cloud - Domoticz",
  6. "disabled": false,
  7. "info": "",
  8. "env": []
  9. },
  10. {
  11. "id": "1b1333f1f00f981d",
  12. "type": "Daikin-Cloud-Controller",
  13. "z": "6d2f931c87bbb1a0",
  14. "name": "Daikin Cloud",
  15. "loglevel": "warn",
  16. "tokensave": "0",
  17. "timeout": "10000",
  18. "retry": "3",
  19. "x": 450,
  20. "y": 360,
  21. "wires": [
  22. [
  23. "23db72d6edfeba77",
  24. "5ff7eb6386c2e166"
  25. ]
  26. ]
  27. },
  28. {
  29. "id": "98b78a8ee3ac4fc5",
  30. "type": "inject",
  31. "z": "6d2f931c87bbb1a0",
  32. "name": "",
  33. "props": [
  34. {
  35. "p": "topic",
  36. "vt": "str"
  37. }
  38. ],
  39. "repeat": "30",
  40. "crontab": "",
  41. "once": true,
  42. "onceDelay": "15",
  43. "topic": "get",
  44. "x": 90,
  45. "y": 360,
  46. "wires": [
  47. [
  48. "3d3e606e9cf7e139"
  49. ]
  50. ]
  51. },
  52. {
  53. "id": "fb0819061dac9a48",
  54. "type": "mqtt out",
  55. "z": "6d2f931c87bbb1a0",
  56. "name": "",
  57. "topic": "",
  58. "qos": "",
  59. "retain": "",
  60. "respTopic": "",
  61. "contentType": "",
  62. "userProps": "",
  63. "correl": "",
  64. "expiry": "",
  65. "broker": "42bc4e80deb9162e",
  66. "x": 1370,
  67. "y": 360,
  68. "wires": []
  69. },
  70. {
  71. "id": "3b3d7c5990d060cf",
  72. "type": "ui_form",
  73. "z": "6d2f931c87bbb1a0",
  74. "name": "Dashboard",
  75. "label": "",
  76. "group": "a06bad650164a668",
  77. "order": 1,
  78. "width": 0,
  79. "height": 0,
  80. "options": [
  81. {
  82. "label": "Create Power Devices",
  83. "value": "CreatePower",
  84. "type": "checkbox",
  85. "required": true,
  86. "rows": null
  87. },
  88. {
  89. "label": "Create Setpoint Devices",
  90. "value": "CreateSetpoint",
  91. "type": "checkbox",
  92. "required": true,
  93. "rows": null
  94. },
  95. {
  96. "label": "Create Mode Devices",
  97. "value": "CreateMode",
  98. "type": "checkbox",
  99. "required": true,
  100. "rows": null
  101. },
  102. {
  103. "label": "Create Fan Direction Devices",
  104. "value": "CreateFanDirection",
  105. "type": "checkbox",
  106. "required": true,
  107. "rows": null
  108. },
  109. {
  110. "label": "Create Fan Speed Devices",
  111. "value": "CreateFanSpeed",
  112. "type": "checkbox",
  113. "required": true,
  114. "rows": null
  115. },
  116. {
  117. "label": "Create Powerful Devices",
  118. "value": "CreatePowerful",
  119. "type": "checkbox",
  120. "required": true,
  121. "rows": null
  122. },
  123. {
  124. "label": "Create Econo Devices",
  125. "value": "CreateEcono",
  126. "type": "checkbox",
  127. "required": true,
  128. "rows": null
  129. },
  130. {
  131. "label": "Create Led Devices",
  132. "value": "CreateLed",
  133. "type": "checkbox",
  134. "required": true,
  135. "rows": null
  136. },
  137. {
  138. "label": "Create Indoor Temperature Devices",
  139. "value": "CreateIndoorTemperature",
  140. "type": "checkbox",
  141. "required": true,
  142. "rows": null
  143. },
  144. {
  145. "label": "Create Outdoor Temperature Devices",
  146. "value": "CreateOutdoorTemperature",
  147. "type": "checkbox",
  148. "required": true,
  149. "rows": null
  150. },
  151. {
  152. "label": "Create kWh Heat Devices",
  153. "value": "CreatekWhHeat",
  154. "type": "checkbox",
  155. "required": true,
  156. "rows": null
  157. },
  158. {
  159. "label": "Create kWh Cool Devices",
  160. "value": "CreatekWhCool",
  161. "type": "checkbox",
  162. "required": true,
  163. "rows": null
  164. },
  165. {
  166. "label": "Create kWh Total Devices",
  167. "value": "CreatekWhTotal",
  168. "type": "checkbox",
  169. "required": true,
  170. "rows": null
  171. }
  172. ],
  173. "formValue": {
  174. "CreatePower": false,
  175. "CreateSetpoint": false,
  176. "CreateMode": false,
  177. "CreateFanDirection": false,
  178. "CreateFanSpeed": false,
  179. "CreatePowerful": false,
  180. "CreateEcono": false,
  181. "CreateLed": false,
  182. "CreateIndoorTemperature": false,
  183. "CreateOutdoorTemperature": false,
  184. "CreatekWhHeat": false,
  185. "CreatekWhCool": false,
  186. "CreatekWhTotal": false
  187. },
  188. "payload": "",
  189. "submit": "Save Settings",
  190. "cancel": "",
  191. "topic": "topic",
  192. "topicType": "msg",
  193. "splitLayout": true,
  194. "className": "",
  195. "x": 1210,
  196. "y": 60,
  197. "wires": [
  198. [
  199. "c0bbb74d7e77274d",
  200. "a5ec7643afb5928a"
  201. ]
  202. ]
  203. },
  204. {
  205. "id": "cabf72fa9eda13de",
  206. "type": "inject",
  207. "z": "6d2f931c87bbb1a0",
  208. "name": "Start",
  209. "props": [
  210. {
  211. "p": "payload"
  212. },
  213. {
  214. "p": "topic",
  215. "vt": "str"
  216. }
  217. ],
  218. "repeat": "",
  219. "crontab": "",
  220. "once": true,
  221. "onceDelay": "0.1",
  222. "topic": "",
  223. "payload": "",
  224. "payloadType": "date",
  225. "x": 110,
  226. "y": 100,
  227. "wires": [
  228. [
  229. "712b9779176aa8f5"
  230. ]
  231. ]
  232. },
  233. {
  234. "id": "06aec73cb0b676ab",
  235. "type": "file",
  236. "z": "6d2f931c87bbb1a0",
  237. "name": "",
  238. "filename": "filename",
  239. "filenameType": "msg",
  240. "appendNewline": false,
  241. "createDir": true,
  242. "overwriteFile": "true",
  243. "encoding": "none",
  244. "x": 1600,
  245. "y": 60,
  246. "wires": [
  247. []
  248. ]
  249. },
  250. {
  251. "id": "b0aff63096645ac2",
  252. "type": "file in",
  253. "z": "6d2f931c87bbb1a0",
  254. "name": "",
  255. "filename": "filename",
  256. "filenameType": "msg",
  257. "format": "utf8",
  258. "chunk": false,
  259. "sendError": false,
  260. "encoding": "none",
  261. "allProps": false,
  262. "x": 560,
  263. "y": 60,
  264. "wires": [
  265. [
  266. "0dc3eb2935ae9b37"
  267. ]
  268. ]
  269. },
  270. {
  271. "id": "ce325a7cdf5cfd18",
  272. "type": "json",
  273. "z": "6d2f931c87bbb1a0",
  274. "name": "",
  275. "property": "payload",
  276. "action": "",
  277. "pretty": false,
  278. "x": 870,
  279. "y": 60,
  280. "wires": [
  281. [
  282. "3b3d7c5990d060cf",
  283. "ceeefc01731f3e0b"
  284. ]
  285. ]
  286. },
  287. {
  288. "id": "e921f6e124e10999",
  289. "type": "comment",
  290. "z": "6d2f931c87bbb1a0",
  291. "name": "Step 2: Set up dashboard (CTRL+SHIFT+D)",
  292. "info": "Fill in all required information in the dashboard.\nBut do not enable start flow yet!\n\nThe dashboard can be opened using CTRL+SHIFT+D or by going to 127.0.0.1:1880/ui/\n\nIf no password is needed for domoticz or your mqtt broker, just leave username and password empty. If everything is filled in, click save.\n\nSelect all devices types you want to create. Don't forget to click save too, as this is a separate dashboard.\n\nOpen the \"Daikin Cloud\" node and enter your username and password you use for the app. This node does not support logins using facebook, so you need to create an account using an e-mailaddress.",
  293. "x": 410,
  294. "y": 20,
  295. "wires": []
  296. },
  297. {
  298. "id": "b59cf1777bd867f4",
  299. "type": "ui_form",
  300. "z": "6d2f931c87bbb1a0",
  301. "name": "Dashboard",
  302. "label": "",
  303. "group": "43745523810d126b",
  304. "order": 1,
  305. "width": 0,
  306. "height": 0,
  307. "options": [
  308. {
  309. "label": "MQTT Broker IP",
  310. "value": "MQTTBrokerIP",
  311. "type": "text",
  312. "required": true,
  313. "rows": null
  314. },
  315. {
  316. "label": "MQTT Broker Port",
  317. "value": "MQTTBrokerPort",
  318. "type": "text",
  319. "required": true,
  320. "rows": null
  321. },
  322. {
  323. "label": "MQTT Broker Username",
  324. "value": "MQTTBrokerUsername",
  325. "type": "text",
  326. "required": false,
  327. "rows": null
  328. },
  329. {
  330. "label": "MQTT Broker Password",
  331. "value": "MQTTBrokerPassword",
  332. "type": "password",
  333. "required": false,
  334. "rows": null
  335. },
  336. {
  337. "label": "Auto Discovery Prefix",
  338. "value": "AutoDiscoveryPrefix",
  339. "type": "text",
  340. "required": true,
  341. "rows": null
  342. },
  343. {
  344. "label": "State Set Prefix",
  345. "value": "StateSetPrefix",
  346. "type": "text",
  347. "required": true,
  348. "rows": null
  349. },
  350. {
  351. "label": "Start Flow",
  352. "value": "StartFlow",
  353. "type": "checkbox",
  354. "required": true,
  355. "rows": null
  356. }
  357. ],
  358. "formValue": {
  359. "MQTTBrokerIP": "",
  360. "MQTTBrokerPort": "",
  361. "MQTTBrokerUsername": "",
  362. "MQTTBrokerPassword": "",
  363. "AutoDiscoveryPrefix": "",
  364. "StateSetPrefix": "",
  365. "StartFlow": false
  366. },
  367. "payload": "",
  368. "submit": "Save Settings",
  369. "cancel": "",
  370. "topic": "topic",
  371. "topicType": "msg",
  372. "splitLayout": false,
  373. "className": "",
  374. "x": 1210,
  375. "y": 140,
  376. "wires": [
  377. [
  378. "58eb59d2a125eb49",
  379. "f21dcc60b22975ad"
  380. ]
  381. ]
  382. },
  383. {
  384. "id": "26ce01afe0babef8",
  385. "type": "file in",
  386. "z": "6d2f931c87bbb1a0",
  387. "name": "",
  388. "filename": "filename",
  389. "filenameType": "msg",
  390. "format": "utf8",
  391. "chunk": false,
  392. "sendError": false,
  393. "encoding": "none",
  394. "allProps": false,
  395. "x": 560,
  396. "y": 140,
  397. "wires": [
  398. [
  399. "1e672b1d07b5f29b"
  400. ]
  401. ]
  402. },
  403. {
  404. "id": "f9b3232c48ec7188",
  405. "type": "file",
  406. "z": "6d2f931c87bbb1a0",
  407. "name": "",
  408. "filename": "",
  409. "appendNewline": false,
  410. "createDir": true,
  411. "overwriteFile": "true",
  412. "encoding": "none",
  413. "x": 1600,
  414. "y": 140,
  415. "wires": [
  416. []
  417. ]
  418. },
  419. {
  420. "id": "79fdd12f2d8a54a1",
  421. "type": "json",
  422. "z": "6d2f931c87bbb1a0",
  423. "name": "",
  424. "property": "payload",
  425. "action": "",
  426. "pretty": false,
  427. "x": 870,
  428. "y": 140,
  429. "wires": [
  430. [
  431. "b59cf1777bd867f4",
  432. "ceeefc01731f3e0b"
  433. ]
  434. ]
  435. },
  436. {
  437. "id": "2f516322be8758a5",
  438. "type": "mqtt in",
  439. "z": "6d2f931c87bbb1a0",
  440. "name": "",
  441. "topic": "",
  442. "qos": "2",
  443. "datatype": "auto",
  444. "broker": "42bc4e80deb9162e",
  445. "nl": false,
  446. "rap": true,
  447. "rh": 0,
  448. "inputs": 1,
  449. "x": 770,
  450. "y": 300,
  451. "wires": [
  452. [
  453. "ed7e3ed0d0411953"
  454. ]
  455. ]
  456. },
  457. {
  458. "id": "58eb59d2a125eb49",
  459. "type": "change",
  460. "z": "6d2f931c87bbb1a0",
  461. "name": "",
  462. "rules": [
  463. {
  464. "t": "set",
  465. "p": "payload",
  466. "pt": "msg",
  467. "to": "payload",
  468. "tot": "msg"
  469. }
  470. ],
  471. "action": "",
  472. "property": "",
  473. "from": "",
  474. "to": "",
  475. "reg": false,
  476. "x": 1220,
  477. "y": 180,
  478. "wires": [
  479. [
  480. "b59cf1777bd867f4",
  481. "4023355498191793"
  482. ]
  483. ]
  484. },
  485. {
  486. "id": "c0bbb74d7e77274d",
  487. "type": "change",
  488. "z": "6d2f931c87bbb1a0",
  489. "name": "",
  490. "rules": [
  491. {
  492. "t": "set",
  493. "p": "payload",
  494. "pt": "msg",
  495. "to": "payload",
  496. "tot": "msg"
  497. }
  498. ],
  499. "action": "",
  500. "property": "",
  501. "from": "",
  502. "to": "",
  503. "reg": false,
  504. "x": 1220,
  505. "y": 100,
  506. "wires": [
  507. [
  508. "3b3d7c5990d060cf",
  509. "4023355498191793"
  510. ]
  511. ]
  512. },
  513. {
  514. "id": "e0eda8a3d289d030",
  515. "type": "function",
  516. "z": "6d2f931c87bbb1a0",
  517. "name": "Set MQTT Connection",
  518. "func": "if ((flow.get(\"MQTTBrokerUsername\") == undefined) || (flow.get(\"MQTTBrokerPassword\") == undefined))\n {\n msg.broker = JSON.parse('{\"broker\": \"' + flow.get(\"MQTTBrokerIP\") + '\", \"port\": ' + flow.get(\"MQTTBrokerPort\") + ', \"force\": true }');\n msg.action = \"connect\";\n node.send(msg) \n }\nelse\n {\n msg.broker = JSON.parse('{\"broker\": \"' + flow.get(\"MQTTBrokerIP\") + '\", \"port\": ' + flow.get(\"MQTTBrokerPort\") + ', \"username\" : \"' + flow.get(\"MQTTBrokerUsername\") + '\", \"password\" : \"' + flow.get(\"MQTTBrokerPassword\") + '\", \"force\": true }');\n msg.action = \"connect\";\n node.send(msg) \n }\n\nmsg.action = \"subscribe\";\nmsg.topic = flow.get(\"StateSetPrefix\")+\"/#\";\nnode.send(msg)\n \nreturn null;\n \n\n\n",
  519. "outputs": 1,
  520. "noerr": 0,
  521. "initialize": "",
  522. "finalize": "",
  523. "libs": [],
  524. "x": 580,
  525. "y": 300,
  526. "wires": [
  527. [
  528. "2f516322be8758a5"
  529. ]
  530. ]
  531. },
  532. {
  533. "id": "ceeefc01731f3e0b",
  534. "type": "function",
  535. "z": "6d2f931c87bbb1a0",
  536. "name": "",
  537. "func": "msg.payload.keys = Object.keys(msg.payload)\nmsg.payload.values = Object.values(msg.payload)\n\nfor (let i = 0; i < msg.payload.keys.length; i++)\n{\n flow.set(msg.payload.keys[i], msg.payload.values[i])\n}\n",
  538. "outputs": 1,
  539. "noerr": 0,
  540. "initialize": "",
  541. "finalize": "",
  542. "libs": [],
  543. "x": 1040,
  544. "y": 100,
  545. "wires": [
  546. []
  547. ]
  548. },
  549. {
  550. "id": "4023355498191793",
  551. "type": "link out",
  552. "z": "6d2f931c87bbb1a0",
  553. "name": "LoadFileIn",
  554. "mode": "link",
  555. "links": [
  556. "2a5f716aa67a0892"
  557. ],
  558. "x": 1415,
  559. "y": 100,
  560. "wires": []
  561. },
  562. {
  563. "id": "2a5f716aa67a0892",
  564. "type": "link in",
  565. "z": "6d2f931c87bbb1a0",
  566. "name": "",
  567. "links": [
  568. "4023355498191793"
  569. ],
  570. "x": 255,
  571. "y": 100,
  572. "wires": [
  573. [
  574. "8212dfe1a2221478"
  575. ]
  576. ]
  577. },
  578. {
  579. "id": "ed7e3ed0d0411953",
  580. "type": "function",
  581. "z": "6d2f931c87bbb1a0",
  582. "name": "Set Devices",
  583. "func": "var mqttmsg = {}\nvar daikinmsg = {}\ndaikinmsg.payload = {}\n\n\n//Set State variables\nif ((msg.topic.includes(\"daikin\")) && (msg.topic.includes(\"state\")))\n{\n flow.set(msg.topic, msg.payload)\n}\n\n\nfor (let i = 0; i < flow.get(\"UnitCount\"); i++)\n\n{\n var ssid = flow.get(\"SSIDUnit\"+i)\n var unitname = flow.get(\"NameUnit\"+i)\n \n //POWER \n if (msg.topic.includes(\"/switch/power/\"+unitname+\"/set\"))\n {\n mqttmsg.topic = \"daikin/switch/power/\" + unitname + \"/state\"\n \n daikinmsg.topic = \"set\"\n daikinmsg.payload.managementPoint = \"climateControl\"\n daikinmsg.payload.dataPoint = \"onOffMode\" \n daikinmsg.payload.ssid = ssid\n \n if (msg.payload == \"ON\") \n {\n mqttmsg.payload = \"ON\"\n daikinmsg.payload.value = \"on\"\n \n }\n else if (msg.payload == \"OFF\") \n {\n mqttmsg.payload = \"OFF\"\n daikinmsg.payload.value = \"off\"\n }\n node.send([[mqttmsg],[null]])\n node.send([[null],[daikinmsg]])\n flow.set(\"SkipRead\", 3)\n }\n \n //SETPOINT\n else if (msg.topic.includes(\"/climate/setpoint/\"+unitname+\"/targetTempCmd\"))\n {\n mqttmsg.topic = \"daikin/climate/setpoint/\" + unitname + \"/state\"\n mqttmsg.payload = msg.payload\n \n daikinmsg.topic = \"set\"\n daikinmsg.payload.managementPoint = \"climateControl\"\n daikinmsg.payload.dataPoint = \"temperatureControl\" \n daikinmsg.payload.ssid = ssid\n //daikinmsg.payload.value = Number(Number(msg.payload.svalue1).toFixed(1))\n daikinmsg.payload.value = Number(msg.payload).toFixed(1)\n\n \n if (flow.get(\"CurrentModeUnit\"+i) == \"cooling\")\n {daikinmsg.payload.dataPointPath = '[\"/operationModes/cooling/setpoints/roomTemperature\"]'}\n if (flow.get(\"CurrentModeUnit\"+i) == \"heating\")\n {daikinmsg.payload.dataPointPath = '[\"/operationModes/heating/setpoints/roomTemperature\"]'}\n if (flow.get(\"CurrentModeUnit\"+i) == \"auto\") \n {daikinmsg.payload.dataPointPath = '[\"/operationModes/auto/setpoints/roomTemperature\"]'}\n \n node.send([[mqttmsg],[null]])\n node.send([[null],[daikinmsg]])\n flow.set(\"SkipRead\", 3)\n }\n \n //MODE\n else if (msg.topic.includes(\"/select/mode/\"+unitname+\"/set\"))\n {\n if (msg.payload == \"off\") \n {\n node.warn(\"Mode cannot be off, please hide off level in domoticz\")\n }\n else\n {\n mqttmsg.topic = \"daikin/select/mode/\" + unitname + \"/state\"\n mqttmsg.payload = msg.payload\n \n daikinmsg.topic = \"set\"\n daikinmsg.payload.managementPoint = \"climateControl\"\n daikinmsg.payload.dataPoint = \"operationMode\" \n daikinmsg.payload.ssid = ssid\n daikinmsg.payload.value = msg.payload\n flow.set(\"CurrentModeUnit\"+i, msg.payload)\n node.send([[mqttmsg],[null]])\n node.send([[null],[daikinmsg]])\n flow.set(\"SkipRead\", 3)\n }\n }\n \n //FANDIRECTION\n else if (msg.topic.includes(\"/select/fandirection/\"+unitname+\"/set\"))\n {\n mqttmsg.topic = \"daikin/select/fandirection/\" + unitname + \"/state\"\n mqttmsg.payload = msg.payload\n \n daikinmsg.topic = \"set\"\n daikinmsg.payload.managementPoint = \"climateControl\"\n daikinmsg.payload.dataPoint = \"fanControl\" \n daikinmsg.payload.ssid = ssid\n \n if (msg.payload == \"Off\")\n {\n horizontal = \"stop\"\n vertical = \"stop\"\n }\n \n if (msg.payload == \"Horizontal\")\n {\n horizontal = \"swing\"\n vertical = \"stop\"\n }\n \n if (msg.payload == \"Vertical\")\n {\n horizontal = \"stop\"\n vertical = \"swing\"\n }\n \n if (msg.payload == \"3D-Swing\")\n {\n horizontal = \"swing\"\n vertical = \"swing\"\n }\n daikinmsg.payload.dataPointPath = '/operationModes/' + flow.get(\"CurrentModeUnit\"+i) + '/fanDirection/horizontal/currentMode'\n daikinmsg.payload.value = horizontal\n node.send([[null],[daikinmsg]]);\n daikinmsg.payload.dataPointPath = '/operationModes/' + flow.get(\"CurrentModeUnit\"+i) + '/fanDirection/vertical/currentMode'\n daikinmsg.payload.value = vertical\n node.send([[null],[daikinmsg]]); \n node.send([[mqttmsg],[null]])\n flow.set(\"SkipRead\", 3)\n }\n \n //FANSPEED\n else if (msg.topic.includes(\"/select/fanspeed/\"+unitname+\"/set\"))\n {\n mqttmsg.topic = \"daikin/select/fanspeed/\" + unitname + \"/state\"\n mqttmsg.payload = msg.payload\n \n daikinmsg.topic = \"set\"\n daikinmsg.payload.managementPoint = \"climateControl\"\n daikinmsg.payload.dataPoint = \"fanControl\" \n daikinmsg.payload.ssid = ssid\n \n if ((msg.payload.includes(\"Level\")) && (flow.get(\"CurrentModeUnit\"+i) != \"dry\"))\n {\n daikinmsg.payload.dataPointPath = '/operationModes/' + flow.get(\"CurrentModeUnit\"+i) + '/fanSpeed/currentMode'\n daikinmsg.payload.value = \"fixed\"\n node.send([[null],[daikinmsg]]); \n \n daikinmsg.payload.dataPointPath = '/operationModes/' + flow.get(\"CurrentModeUnit\"+i) + '/fanSpeed/modes/fixed'\n daikinmsg.payload.value = Number(msg.payload.slice(-1))\n node.send([[null],[daikinmsg]]);\n }\n \n if ((msg.payload == (\"Auto\")) && (flow.get(\"CurrentModeUnit\"+i) != \"dry\"))\n {\n daikinmsg.payload.dataPointPath = '/operationModes/' + flow.get(\"CurrentModeUnit\"+i) + '/fanSpeed/currentMode'\n daikinmsg.payload.value = \"auto\"\n node.send([[null],[daikinmsg]]);\n }\n \n if ((msg.payload == (\"Quiet\")) && (flow.get(\"CurrentModeUnit\"+i) != \"dry\"))\n {\n daikinmsg.payload.dataPointPath = '/operationModes/' + flow.get(\"CurrentModeUnit\"+i) + '/fanSpeed/currentMode'\n daikinmsg.payload.value = \"quiet\"\n node.send([[null],[daikinmsg]]);\n }\n \n if (msg.payload == (\"Off\"))\n {\n node.warn(\"Fan Speed cannot be off, please hide off level in domoticz\")\n }\n \n node.send([[mqttmsg],[null]])\n flow.set(\"SkipRead\", 3)\n }\n \n //POWERFUL\n else if (msg.topic.includes(\"/switch/powerful/\"+unitname+\"/set\"))\n {\n mqttmsg.topic = \"daikin/switch/powerful/\" + unitname + \"/state\"\n\n \n daikinmsg.topic = \"set\"\n daikinmsg.payload.managementPoint = \"climateControl\"\n daikinmsg.payload.dataPoint = \"powerfulMode\" \n daikinmsg.payload.ssid = ssid\n \n if (msg.payload == \"ON\") \n {\n mqttmsg.payload = \"ON\"\n daikinmsg.payload.value = \"on\"\n \n }\n else if (msg.payload == \"OFF\") \n {\n mqttmsg.payload = \"OFF\"\n daikinmsg.payload.value = \"off\"\n }\n node.send([[mqttmsg],[null]])\n node.send([[null],[daikinmsg]])\n flow.set(\"SkipRead\", 3)\n }\n \n //ECONO\n else if (msg.topic.includes(\"/switch/econo/\"+unitname+\"/set\"))\n {\n mqttmsg.topic = \"daikin/switch/econo/\" + unitname + \"/state\"\n\n \n daikinmsg.topic = \"set\"\n daikinmsg.payload.managementPoint = \"climateControl\"\n daikinmsg.payload.dataPoint = \"econoMode\" \n daikinmsg.payload.ssid = ssid\n \n if (msg.payload == \"ON\") \n {\n mqttmsg.payload = \"ON\"\n daikinmsg.payload.value = \"on\"\n \n }\n else if (msg.payload == \"OFF\") \n {\n mqttmsg.payload = \"OFF\"\n daikinmsg.payload.value = \"off\"\n }\n node.send([[mqttmsg],[null]])\n node.send([[null],[daikinmsg]])\n flow.set(\"SkipRead\", 3)\n }\n \n //LED \n if (msg.topic.includes(\"/switch/led/\"+unitname+\"/set\"))\n {\n mqttmsg.topic = \"daikin/switch/led/\" + unitname + \"/state\"\n \n daikinmsg.topic = \"set\"\n daikinmsg.payload.managementPoint = \"gateway\"\n daikinmsg.payload.dataPoint = \"ledEnabled\" \n daikinmsg.payload.ssid = ssid\n \n if (msg.payload == \"ON\") \n {\n mqttmsg.payload = \"ON\"\n daikinmsg.payload.value = true\n \n }\n else if (msg.payload == \"OFF\") \n {\n mqttmsg.payload = \"OFF\"\n daikinmsg.payload.value = false\n }\n node.send([[mqttmsg],[null]])\n node.send([[null],[daikinmsg]])\n flow.set(\"SkipRead\", 3)\n }\n \n}\n\nreturn null",
  584. "outputs": 2,
  585. "noerr": 0,
  586. "initialize": "",
  587. "finalize": "",
  588. "libs": [],
  589. "x": 1130,
  590. "y": 300,
  591. "wires": [
  592. [
  593. "fb0819061dac9a48"
  594. ],
  595. [
  596. "04be43bdb7384602"
  597. ]
  598. ],
  599. "outputLabels": [
  600. "To MQTT",
  601. "To Daikin Cloud"
  602. ]
  603. },
  604. {
  605. "id": "d3bb7b1fd84408e6",
  606. "type": "function",
  607. "z": "6d2f931c87bbb1a0",
  608. "name": "Read Devices",
  609. "func": "//Save all state messages first\nconst currentminutes = new Date().getMinutes();\n\n for (var i = 0; i < msg.payload.length; i++)\n {\n \n var StateMessage = {};\n var unitname = flow.get(\"NameUnit\"+i)\n \n if ((flow.get(\"SkipRead\") == 0) || (flow.get(\"SkipRead\") == undefined))\n {\n //POWER\n if (msg.payload[i].managementPoints.climateControl.onOffMode.value == \"off\") \n {\n StateMessage.payload = \"OFF\"\n if (flow.get(\"daikin/switch/power/\"+unitname+\"/state\") != \"OFF\")\n {\n StateMessage.topic = \"daikin/switch/power/\" + unitname + \"/state\"\n StateMessage.payload = \"OFF\"\n node.send(StateMessage);\n } \n } \n else \n {\n StateMessage.payload = \"ON\"\n if (flow.get(\"daikin/switch/power/\"+unitname+\"/state\") != \"ON\")\n {\n StateMessage.topic = \"daikin/switch/power/\" + unitname + \"/state\"\n StateMessage.payload = \"ON\"\n node.send(StateMessage);\n }\n }\n \n \n //SETPOINT \n if ((flow.get(\"CurrentModeUnit\"+i) != \"dry\") && (flow.get(\"CurrentModeUnit\"+i) != \"fanOnly\"))\n {\n setpoint = eval('msg.payload[i].managementPoints.climateControl.temperatureControl[\"/operationModes/' + flow.get(\"CurrentModeUnit\"+i) + '/setpoints/roomTemperature\"].value')\n }\n else\n {\n setpoint = msg.payload[i].managementPoints.climateControl.temperatureControl[\"/operationModes/cooling/setpoints/roomTemperature\"].value\n }\n\n if ((flow.get(\"daikin/climate/setpoint/\"+unitname+\"/state\") != setpoint.toFixed(2)) || (currentminutes == 30)) //|| ((currentminutes % 5 === 0)))\n {\n StateMessage.topic = \"daikin/climate/setpoint/\" + unitname + \"/state\"\n StateMessage.payload = setpoint.toFixed(2)\n node.send(StateMessage);\n }\n \n //MODE\n if (flow.get(\"daikin/select/mode/\"+unitname+\"/state\") != msg.payload[i].managementPoints.climateControl.operationMode.value)\n {\n StateMessage.topic = \"daikin/select/mode/\" + unitname + \"/state\"\n StateMessage.payload =msg.payload[i].managementPoints.climateControl.operationMode.value\n flow.set(\"CurrentModeUnit\"+i, msg.payload[i].managementPoints.climateControl.operationMode.value)\n node.send(StateMessage);\n }\n \n //FANDIRECTION\n //Streepje in 3D-Swing nakijken domoticz\n horizontal = eval('msg.payload[i].managementPoints.climateControl.fanControl[\"/operationModes/' + flow.get(\"CurrentModeUnit\"+i) + '/fanDirection/horizontal/currentMode\"].value')\n vertical = eval('msg.payload[i].managementPoints.climateControl.fanControl[\"/operationModes/' + flow.get(\"CurrentModeUnit\"+i) + '/fanDirection/vertical/currentMode\"].value')\n \n if ((horizontal == \"stop\") && (vertical == \"stop\")) {fandirection = \"Off\"}\n else if ((horizontal == \"swing\") && (vertical == \"stop\")) {fandirection = \"Horizontal\"}\n else if ((horizontal == \"stop\") && (vertical == \"swing\")) {fandirection = \"Vertical\"}\n else if ((horizontal == \"swing\") && (vertical == \"swing\")) {fandirection = \"3D-Swing\"}\n \n if (flow.get(\"daikin/select/fandirection/\"+unitname+\"/state\") != fandirection)\n {\n StateMessage.topic = \"daikin/select/fandirection/\" + unitname + \"/state\"\n StateMessage.payload = fandirection\n node.send(StateMessage);\n }\n \n //FANSPEED\n //MAG NIET OFF ZIJN\n FanSpeedMode = eval('msg.payload[i].managementPoints.climateControl.fanControl[\"/operationModes/' + flow.get(\"CurrentModeUnit\"+i) + '/fanSpeed/currentMode\"].value')\n FanSpeedFixed = eval('msg.payload[i].managementPoints.climateControl.fanControl[\"/operationModes/' + flow.get(\"CurrentModeUnit\"+i) + '/fanSpeed/modes/fixed\"].value')\n \n if (FanSpeedMode == \"fixed\") {fanspeed = \"Level \" + FanSpeedFixed}\n else if (FanSpeedMode == \"auto\") {fanspeed = \"Auto\"}\n else if (FanSpeedMode == \"quiet\") {fanspeed = \"Quiet\"} \n \n if (flow.get(\"daikin/select/fanspeed/\"+unitname+\"/state\") != fanspeed)\n {\n StateMessage.topic = \"daikin/select/fanspeed/\" + unitname + \"/state\"\n StateMessage.payload = fanspeed\n node.send(StateMessage);\n }\n \n //POWERFUL\n if (msg.payload[i].managementPoints.climateControl.powerfulMode.value == \"off\") \n {\n StateMessage.payload = \"OFF\"\n if (flow.get(\"daikin/switch/powerful/\"+unitname+\"/state\") != \"OFF\")\n {\n StateMessage.topic = \"daikin/switch/powerful/\" + unitname + \"/state\"\n StateMessage.payload = \"OFF\"\n node.send(StateMessage);\n } \n } \n else \n {\n StateMessage.payload = \"ON\"\n if (flow.get(\"daikin/switch/powerful/\"+unitname+\"/state\") != \"ON\")\n {\n StateMessage.topic = \"daikin/switch/powerful/\" + unitname + \"/state\"\n StateMessage.payload = \"ON\"\n node.send(StateMessage);\n }\n }\n \n //ECONO\n if (msg.payload[i].managementPoints.climateControl.econoMode.value == \"off\") \n {\n StateMessage.payload = \"OFF\"\n if (flow.get(\"daikin/switch/econo/\"+unitname+\"/state\") != \"OFF\")\n {\n StateMessage.topic = \"daikin/switch/econo/\" + unitname + \"/state\"\n StateMessage.payload = \"OFF\"\n node.send(StateMessage);\n } \n } \n else \n {\n StateMessage.payload = \"ON\"\n if (flow.get(\"daikin/switch/econo/\"+unitname+\"/state\") != \"ON\")\n {\n StateMessage.topic = \"daikin/switch/econo/\" + unitname + \"/state\"\n StateMessage.payload = \"ON\"\n node.send(StateMessage);\n }\n }\n \n \n \n //LED\n if (msg.payload[i].managementPoints.gateway.ledEnabled.value == false) \n {\n StateMessage.payload = \"OFF\"\n if (flow.get(\"daikin/switch/led/\"+unitname+\"/state\") != \"OFF\")\n {\n StateMessage.topic = \"daikin/switch/led/\" + unitname + \"/state\"\n StateMessage.payload = \"OFF\"\n node.send(StateMessage);\n } \n } \n else \n {\n StateMessage.payload = \"ON\"\n if (flow.get(\"daikin/switch/led/\"+unitname+\"/state\") != \"ON\")\n {\n StateMessage.topic = \"daikin/switch/led/\" + unitname + \"/state\"\n StateMessage.payload = \"ON\"\n node.send(StateMessage);\n }\n }\n } // End of skipread\n \n //INDOOR TEMPERATURE\n indoortemp = msg.payload[i].managementPoints.climateControl.sensoryData[\"/roomTemperature\"].value\n \n if ((flow.get(\"daikin/sensor/indoor_temp/\"+unitname+\"/state\") != indoortemp) || (currentminutes == 30)) //|| ((currentminutes % 5 === 0)\n {\n StateMessage.topic = \"daikin/sensor/indoor_temp/\" + unitname + \"/state\"\n StateMessage.payload = indoortemp\n node.send(StateMessage);\n } \n \n //OUTDOOR TEMPERATURE\n outdoortemp = msg.payload[i].managementPoints.climateControl.sensoryData[\"/outdoorTemperature\"].value\n \n if ((flow.get(\"daikin/sensor/outdoor_temp/\"+unitname+\"/state\") != outdoortemp) || (currentminutes == 30)) //|| ((currentminutes % 5 === 0) \n {\n StateMessage.topic = \"daikin/sensor/outdoor_temp/\" + unitname + \"/state\"\n StateMessage.payload = outdoortemp\n node.send(StateMessage);\n }\n\n }\n\nif (flow.get(\"SkipRead\") > 0)\n{\nflow.set(\"SkipRead\", (flow.get(\"SkipRead\") - 1))\n}\n\nreturn null;",
  610. "outputs": 1,
  611. "noerr": 0,
  612. "initialize": "",
  613. "finalize": "",
  614. "libs": [],
  615. "x": 1140,
  616. "y": 420,
  617. "wires": [
  618. [
  619. "fb0819061dac9a48"
  620. ]
  621. ]
  622. },
  623. {
  624. "id": "04be43bdb7384602",
  625. "type": "link out",
  626. "z": "6d2f931c87bbb1a0",
  627. "name": "",
  628. "mode": "link",
  629. "links": [
  630. "af4b2817b22db067"
  631. ],
  632. "x": 1235,
  633. "y": 320,
  634. "wires": []
  635. },
  636. {
  637. "id": "af4b2817b22db067",
  638. "type": "link in",
  639. "z": "6d2f931c87bbb1a0",
  640. "name": "",
  641. "links": [
  642. "04be43bdb7384602"
  643. ],
  644. "x": 335,
  645. "y": 360,
  646. "wires": [
  647. [
  648. "1b1333f1f00f981d"
  649. ]
  650. ]
  651. },
  652. {
  653. "id": "5ff7eb6386c2e166",
  654. "type": "rbe",
  655. "z": "6d2f931c87bbb1a0",
  656. "name": "Pass once",
  657. "func": "rbe",
  658. "gap": "",
  659. "start": "",
  660. "inout": "out",
  661. "septopics": false,
  662. "property": "payload.length",
  663. "topi": "topic",
  664. "x": 790,
  665. "y": 360,
  666. "wires": [
  667. [
  668. "6c947aab21954c08"
  669. ]
  670. ]
  671. },
  672. {
  673. "id": "93e07b6a0cbf9e0b",
  674. "type": "function",
  675. "z": "6d2f931c87bbb1a0",
  676. "name": "Read kWh",
  677. "func": "if ((flow.get(\"CreatekWhCool\") == true) || (flow.get(\"CreatekWhHeat\") == true) || (flow.get(\"CreatekWhTotal\") == true))\n{\n const currentminutes = new Date().getMinutes();\n var StateMessage = {}\n var kWhData = {}\n kWhData.payload = \"\"\n var previouskwhcool\n var previouskwhheat\n var firstrun = false\n var writetofile = false\n \n for (let i = 0; i < msg.payload.length; i++)\n {\n \n var CoolKWHarray = []\n var HeatKWHarray = []\n \n \n CoolKWHarray = msg.payload[i].managementPoints.climateControl.consumptionData[\"/electrical\"].cooling.d\n HeatKWHarray = msg.payload[i].managementPoints.climateControl.consumptionData[\"/electrical\"].heating.d\n \n var dailykwhcool = CoolKWHarray.reduce(function(a, b){return a + b*10;}, 0);\n var dailykwhheat = HeatKWHarray.reduce(function(a, b){return a + b*10;}, 0);\n \n if (flow.get(flow.get(\"NameUnit\"+i)+\"TotalkWhCool\") == undefined) \n {\n flow.set(flow.get(\"NameUnit\"+i)+\"TotalkWhCool\", 0)\n totalkwhcool = 0\n firstrun = true\n //First run, set kWh counter to zero.\n StateMessage.topic = \"daikin/sensor/kwh_cool/\" + flow.get(\"NameUnit\"+i) + \"/state\"\n StateMessage.payload = \"0\"\n node.send([[StateMessage], null]) \n }\n else\n {\n totalkwhcool = flow.get(flow.get(\"NameUnit\"+i)+\"TotalkWhCool\")\n }\n \n if (flow.get(flow.get(\"NameUnit\"+i)+\"PreviouskWhCool\") == undefined)\n {previouskwhcool = 0; flow.set(flow.get(\"NameUnit\"+i)+\"PreviouskWhCool\", 0)}\n else\n {previouskwhcool = flow.get(flow.get(\"NameUnit\"+i)+\"PreviouskWhCool\")}\n\n \n if (flow.get(flow.get(\"NameUnit\"+i)+\"TotalkWhHeat\") == undefined) \n {\n \n flow.set(flow.get(\"NameUnit\"+i)+\"TotalkWhHeat\", 0) \n totalkwhheat = 0\n firstrun = true\n //First run, set kWh counter to zero.\n StateMessage.topic = \"daikin/sensor/kwh_heat/\" + flow.get(\"NameUnit\"+i) + \"/state\"\n StateMessage.payload = \"0\"\n node.send([[StateMessage], null]) \n }\n else\n {\n totalkwhheat = flow.get(flow.get(\"NameUnit\"+i)+\"TotalkWhHeat\")\n }\n \n if (flow.get(flow.get(\"NameUnit\"+i)+\"PreviouskWhHeat\") == undefined)\n {previouskwhheat = 0; flow.set(flow.get(\"NameUnit\"+i)+\"PreviouskWhHeat\", 0)}\n else\n {previouskwhheat = flow.get(flow.get(\"NameUnit\"+i)+\"PreviouskWhHeat\")}\n \n //Previous can only be bigger if a new day started (so values of previous were deleted from the daikin array)\n if ((previouskwhcool) > (dailykwhcool)) {previouskwhcool = dailykwhcool; flow.set(flow.get(\"NameUnit\"+i)+\"PreviouskWhCool\", previouskwhcool); writetofile = true}\n if ((previouskwhheat) > (dailykwhheat)) {previouskwhheat = dailykwhheat; flow.set(flow.get(\"NameUnit\"+i)+\"PreviouskWhHeat\", previouskwhheat); writetofile = true}\n \n //Send Updated kWh to domoticz\n //Cool\n if ((totalkwhcool + dailykwhcool) > (previouskwhcool + totalkwhcool))\n {\n StateMessage.topic = \"daikin/sensor/kwh_cool/\" + flow.get(\"NameUnit\"+i) + \"/state\"\n StateMessage.payload = ((totalkwhcool + (dailykwhcool - previouskwhcool))/10).toFixed(1)\n if (flow.get(\"CreatekWhCool\") == true) {node.send([[StateMessage], null])}\n totalkwhcool = (totalkwhcool + (dailykwhcool - previouskwhcool))\n previouskwhcool= dailykwhcool\n flow.set(flow.get(\"NameUnit\"+i)+\"PreviouskWhCool\", previouskwhcool)\n flow.set(flow.get(\"NameUnit\"+i)+\"TotalkWhCool\", totalkwhcool)\n writetofile = true\n }\n //Heat \n if ((totalkwhheat + dailykwhheat) > (previouskwhheat + totalkwhheat))\n {\n StateMessage.topic = \"daikin/sensor/kwh_heat/\" + flow.get(\"NameUnit\"+i) + \"/state\"\n StateMessage.payload = ((totalkwhheat + (dailykwhheat - previouskwhheat))/10).toFixed(1)\n if (flow.get(\"CreatekWhHeat\") == true) {node.send([[StateMessage], null])} \n totalkwhheat = (totalkwhheat + (dailykwhheat - previouskwhheat))\n previouskwhheat = dailykwhheat\n flow.set(flow.get(\"NameUnit\"+i)+\"PreviouskWhHeat\", previouskwhheat)\n flow.set(flow.get(\"NameUnit\"+i)+\"TotalkWhHeat\", totalkwhheat)\n writetofile = true\n }\n //Total \n if ((totalkwhcool + dailykwhcool + totalkwhheat + dailykwhheat) > (previouskwhcool + totalkwhcool + previouskwhheat + totalkwhheat))\n {\n StateMessage.topic = \"daikin/sensor/kwh_total/\" + flow.get(\"NameUnit\"+i) + \"/state\"\n StateMessage.payload = (((totalkwhcool + (dailykwhcool - previouskwhcool)) + (totalkwhheat + (dailykwhheat - previouskwhheat)))/10).toFixed(1)\n if (flow.get(\"CreatekWhTotal\") == true) {node.send([[StateMessage], null])} \n }\n\n //Send current kWh to domoticz (avoid sensor timeout)\n if ((currentminutes == 30) && (writetofile == false))\n {\n //Cool\n StateMessage.topic = \"daikin/sensor/kwh_cool/\" + flow.get(\"NameUnit\"+i) + \"/state\"\n StateMessage.payload = (flow.get(flow.get(\"NameUnit\"+i)+\"TotalkWhCool\")/10).toFixed(1) \n if (flow.get(\"CreatekWhCool\") == true) {node.send([[StateMessage], null])}\n //Heat\n StateMessage.topic = \"daikin/sensor/kwh_heat/\" + flow.get(\"NameUnit\"+i) + \"/state\"\n StateMessage.payload = (flow.get(flow.get(\"NameUnit\"+i)+\"TotalkWhHeat\")/10).toFixed(1) \n if (flow.get(\"CreatekWhHeat\") == true) {node.send([[StateMessage], null])} \n //Total\n StateMessage.topic = \"daikin/sensor/kwh_total/\" + flow.get(\"NameUnit\"+i) + \"/state\"\n StateMessage.payload = ((flow.get(flow.get(\"NameUnit\"+i)+\"TotalkWhCool\")/10) + (flow.get(flow.get(\"NameUnit\"+i)+\"TotalkWhHeat\")/10)).toFixed(1) \n if (flow.get(\"CreatekWhTotal\") == true) {node.send([[StateMessage], null])} \n }\n \n kWhData.payload= '\"'+ flow.get(\"NameUnit\"+i) + 'TotalkWhCool\":\"' + totalkwhcool.toFixed(1) +'\", \"' + flow.get(\"NameUnit\"+i) + 'TotalkWhHeat\":\"' + totalkwhheat.toFixed(1) +'\", \"' + flow.get(\"NameUnit\"+i) + 'PreviouskWhCool\":\"' + previouskwhcool.toFixed(1) +'\", \"' + flow.get(\"NameUnit\"+i) + 'PreviouskWhHeat\":\"' + previouskwhheat.toFixed(1) +'\"'\n if (kWhData.string == undefined)\n {\n kWhData.string = \"{\" + kWhData.payload \n }\n else\n {\n kWhData.string = kWhData.string + \", \" + kWhData.payload \n }\n }\n \n kWhData.string = kWhData.string + \"}\"\n kWhData.payload = kWhData.string\n if (writetofile == true)\n {\n node.send([null, [kWhData]])\n }\n \n} \n return null;",
  678. "outputs": 2,
  679. "noerr": 0,
  680. "initialize": "",
  681. "finalize": "",
  682. "libs": [],
  683. "x": 1130,
  684. "y": 500,
  685. "wires": [
  686. [
  687. "fb0819061dac9a48"
  688. ],
  689. [
  690. "5491c5331ef0db4e"
  691. ]
  692. ]
  693. },
  694. {
  695. "id": "60e2f4ef4737cb7c",
  696. "type": "file",
  697. "z": "6d2f931c87bbb1a0",
  698. "name": "",
  699. "filename": "",
  700. "appendNewline": false,
  701. "createDir": false,
  702. "overwriteFile": "true",
  703. "encoding": "none",
  704. "x": 1120,
  705. "y": 580,
  706. "wires": [
  707. []
  708. ]
  709. },
  710. {
  711. "id": "7a07e52fc7e0fd6e",
  712. "type": "file in",
  713. "z": "6d2f931c87bbb1a0",
  714. "name": "",
  715. "filename": "filename",
  716. "filenameType": "msg",
  717. "format": "utf8",
  718. "chunk": false,
  719. "sendError": false,
  720. "encoding": "none",
  721. "allProps": false,
  722. "x": 560,
  723. "y": 220,
  724. "wires": [
  725. [
  726. "e2d3b86566515530"
  727. ]
  728. ]
  729. },
  730. {
  731. "id": "51447b07a02a9f39",
  732. "type": "function",
  733. "z": "6d2f931c87bbb1a0",
  734. "name": "Read kwhData File on Start",
  735. "func": "msg.payload.keys = Object.keys(msg.payload)\nmsg.payload.values = Object.values(msg.payload)\n\nfor (let i = 0; i < msg.payload.keys.length; i++)\n{\n flow.set(msg.payload.keys[i], Number(msg.payload.values[i]))\n}\n\nreturn null",
  736. "outputs": 1,
  737. "noerr": 0,
  738. "initialize": "",
  739. "finalize": "",
  740. "libs": [],
  741. "x": 880,
  742. "y": 220,
  743. "wires": [
  744. []
  745. ]
  746. },
  747. {
  748. "id": "e2d3b86566515530",
  749. "type": "json",
  750. "z": "6d2f931c87bbb1a0",
  751. "name": "",
  752. "property": "payload",
  753. "action": "",
  754. "pretty": false,
  755. "x": 690,
  756. "y": 220,
  757. "wires": [
  758. [
  759. "51447b07a02a9f39"
  760. ]
  761. ]
  762. },
  763. {
  764. "id": "8212dfe1a2221478",
  765. "type": "function",
  766. "z": "6d2f931c87bbb1a0",
  767. "name": "Set File Location",
  768. "func": "msg.filename = flow.get(\"ConfigurationFilePath\")+\"MQTTADSettings\"\nnode.send([[msg], null, null])\n\nmsg.filename = flow.get(\"ConfigurationFilePath\")+\"DomoticzSettings\"\nnode.send([null, [msg], null])\n\nmsg.filename = flow.get(\"ConfigurationFilePath\")+\"kwhData\"\nnode.send([null, null, [msg]])\n\nreturn null;",
  769. "outputs": 3,
  770. "noerr": 0,
  771. "initialize": "",
  772. "finalize": "",
  773. "libs": [],
  774. "x": 370,
  775. "y": 140,
  776. "wires": [
  777. [
  778. "b0aff63096645ac2"
  779. ],
  780. [
  781. "26ce01afe0babef8"
  782. ],
  783. [
  784. "7a07e52fc7e0fd6e"
  785. ]
  786. ]
  787. },
  788. {
  789. "id": "a5ec7643afb5928a",
  790. "type": "function",
  791. "z": "6d2f931c87bbb1a0",
  792. "name": "Set File Location",
  793. "func": "msg.filename = flow.get(\"ConfigurationFilePath\")+\"MQTTADSettings\"\nreturn msg;",
  794. "outputs": 1,
  795. "noerr": 0,
  796. "initialize": "",
  797. "finalize": "",
  798. "libs": [],
  799. "x": 1410,
  800. "y": 60,
  801. "wires": [
  802. [
  803. "06aec73cb0b676ab"
  804. ]
  805. ]
  806. },
  807. {
  808. "id": "f21dcc60b22975ad",
  809. "type": "function",
  810. "z": "6d2f931c87bbb1a0",
  811. "name": "Set File Location",
  812. "func": "msg.filename = flow.get(\"ConfigurationFilePath\")+\"DomoticzSettings\"\n\nreturn msg;",
  813. "outputs": 1,
  814. "noerr": 0,
  815. "initialize": "",
  816. "finalize": "",
  817. "libs": [],
  818. "x": 1410,
  819. "y": 140,
  820. "wires": [
  821. [
  822. "f9b3232c48ec7188"
  823. ]
  824. ]
  825. },
  826. {
  827. "id": "5491c5331ef0db4e",
  828. "type": "function",
  829. "z": "6d2f931c87bbb1a0",
  830. "name": "Set File Location",
  831. "func": "msg.filename = flow.get(\"ConfigurationFilePath\")+\"kwhData\"\n\nreturn msg;",
  832. "outputs": 1,
  833. "noerr": 0,
  834. "initialize": "",
  835. "finalize": "",
  836. "libs": [],
  837. "x": 1150,
  838. "y": 540,
  839. "wires": [
  840. [
  841. "60e2f4ef4737cb7c"
  842. ]
  843. ]
  844. },
  845. {
  846. "id": "bae0a50d923f4070",
  847. "type": "comment",
  848. "z": "6d2f931c87bbb1a0",
  849. "name": "Step1: Configuration File",
  850. "info": "Set the location of the configuration files in the Configuration File node. \n\nFor example /home/pi/Daikinconfig/\n\nDon't forget the / at the end and beginning.\nThe files are used to store your dashboard settings, and to store kwh data in case you have to restart node red.\n\nNow deploy the flow in nodered.",
  851. "x": 150,
  852. "y": 60,
  853. "wires": []
  854. },
  855. {
  856. "id": "712b9779176aa8f5",
  857. "type": "change",
  858. "z": "6d2f931c87bbb1a0",
  859. "name": "Configuration File",
  860. "rules": [
  861. {
  862. "t": "set",
  863. "p": "ConfigurationFilePath",
  864. "pt": "flow",
  865. "to": "/home/pi/DaikinConfig/",
  866. "tot": "str"
  867. }
  868. ],
  869. "action": "",
  870. "property": "",
  871. "from": "",
  872. "to": "",
  873. "reg": false,
  874. "x": 150,
  875. "y": 140,
  876. "wires": [
  877. [
  878. "8212dfe1a2221478"
  879. ]
  880. ],
  881. "info": "Choose a place where the configuration files and the ...."
  882. },
  883. {
  884. "id": "3d3e606e9cf7e139",
  885. "type": "switch",
  886. "z": "6d2f931c87bbb1a0",
  887. "name": "Start Flow",
  888. "property": "StartFlow",
  889. "propertyType": "flow",
  890. "rules": [
  891. {
  892. "t": "true"
  893. }
  894. ],
  895. "checkall": "true",
  896. "repair": false,
  897. "outputs": 1,
  898. "x": 220,
  899. "y": 360,
  900. "wires": [
  901. [
  902. "4c67bcf40c159646",
  903. "1b1333f1f00f981d"
  904. ]
  905. ]
  906. },
  907. {
  908. "id": "4c67bcf40c159646",
  909. "type": "rbe",
  910. "z": "6d2f931c87bbb1a0",
  911. "name": "Pass once",
  912. "func": "rbe",
  913. "gap": "",
  914. "start": "",
  915. "inout": "out",
  916. "septopics": false,
  917. "property": "topic",
  918. "topi": "topic",
  919. "x": 390,
  920. "y": 300,
  921. "wires": [
  922. [
  923. "e0eda8a3d289d030"
  924. ]
  925. ]
  926. },
  927. {
  928. "id": "0dc3eb2935ae9b37",
  929. "type": "change",
  930. "z": "6d2f931c87bbb1a0",
  931. "name": "",
  932. "rules": [
  933. {
  934. "t": "set",
  935. "p": "topic",
  936. "pt": "msg",
  937. "to": "payload",
  938. "tot": "msg"
  939. }
  940. ],
  941. "action": "",
  942. "property": "",
  943. "from": "",
  944. "to": "",
  945. "reg": false,
  946. "x": 710,
  947. "y": 60,
  948. "wires": [
  949. [
  950. "ce325a7cdf5cfd18"
  951. ]
  952. ]
  953. },
  954. {
  955. "id": "1e672b1d07b5f29b",
  956. "type": "change",
  957. "z": "6d2f931c87bbb1a0",
  958. "name": "",
  959. "rules": [
  960. {
  961. "t": "set",
  962. "p": "topic",
  963. "pt": "msg",
  964. "to": "payload",
  965. "tot": "msg"
  966. }
  967. ],
  968. "action": "",
  969. "property": "",
  970. "from": "",
  971. "to": "",
  972. "reg": false,
  973. "x": 710,
  974. "y": 140,
  975. "wires": [
  976. [
  977. "79fdd12f2d8a54a1"
  978. ]
  979. ]
  980. },
  981. {
  982. "id": "6c947aab21954c08",
  983. "type": "function",
  984. "z": "6d2f931c87bbb1a0",
  985. "name": "Set UnitData",
  986. "func": "if (flow.get(\"UnitCount\") == undefined)\n{\n for (let i = 0; i < msg.payload.length; i++)\n {\n flow.set(\"UnitCount\", msg.payload.length)\n flow.set(\"CurrentModeUnit\"+i, msg.payload[i].managementPoints.climateControl.operationMode.value )\n flow.set(\"SSIDUnit\"+i,msg.payload[i].managementPoints.gateway.ssid.value)\n flow.set(\"NameUnit\"+i,msg.payload[i].managementPoints.climateControl.name.value)\n flow.set(\"IDUnit\"+i,msg.payload[i].desc._id) \n }\n}\nreturn msg;",
  987. "outputs": 1,
  988. "noerr": 0,
  989. "initialize": "",
  990. "finalize": "",
  991. "libs": [],
  992. "x": 950,
  993. "y": 360,
  994. "wires": [
  995. [
  996. "797fd7f2d05498c3"
  997. ]
  998. ]
  999. },
  1000. {
  1001. "id": "d5ef248c5c73a795",
  1002. "type": "delay",
  1003. "z": "6d2f931c87bbb1a0",
  1004. "name": "",
  1005. "pauseType": "rate",
  1006. "timeout": "5",
  1007. "timeoutUnits": "seconds",
  1008. "rate": "1",
  1009. "nbRateUnits": "1",
  1010. "rateUnits": "minute",
  1011. "randomFirst": "1",
  1012. "randomLast": "5",
  1013. "randomUnits": "seconds",
  1014. "drop": true,
  1015. "allowrate": false,
  1016. "outputs": 1,
  1017. "x": 950,
  1018. "y": 460,
  1019. "wires": [
  1020. [
  1021. "d3bb7b1fd84408e6",
  1022. "93e07b6a0cbf9e0b"
  1023. ]
  1024. ]
  1025. },
  1026. {
  1027. "id": "23db72d6edfeba77",
  1028. "type": "delay",
  1029. "z": "6d2f931c87bbb1a0",
  1030. "name": "",
  1031. "pauseType": "delay",
  1032. "timeout": "2",
  1033. "timeoutUnits": "seconds",
  1034. "rate": "1",
  1035. "nbRateUnits": "1",
  1036. "rateUnits": "second",
  1037. "randomFirst": "1",
  1038. "randomLast": "5",
  1039. "randomUnits": "seconds",
  1040. "drop": false,
  1041. "allowrate": false,
  1042. "outputs": 1,
  1043. "x": 800,
  1044. "y": 460,
  1045. "wires": [
  1046. [
  1047. "d5ef248c5c73a795"
  1048. ]
  1049. ]
  1050. },
  1051. {
  1052. "id": "797fd7f2d05498c3",
  1053. "type": "function",
  1054. "z": "6d2f931c87bbb1a0",
  1055. "name": "Create Devices",
  1056. "func": "var switchmsg = {}\nfor (let i = 0; i < msg.payload.length; i++)\n {\n ssid = msg.payload[i].managementPoints.gateway.ssid.value\n name = msg.payload[i].managementPoints.climateControl.name.value\n id = msg.payload[i].desc._id\n switchmsg.retain = true\n \n //Power ON/OFF\n if (flow.get(\"CreatePower\") == true) \n {\n //switchmsg.retain = true\n switchmsg.topic = flow.get(\"AutoDiscoveryPrefix\") + '/switch/power/' + name + '/config'\n switchmsg.payload = '{\"name\": \"Daikin ' + name + ' Power\", \"command_topic\": \"' + flow.get(\"StateSetPrefix\") + '/switch/power/' + name + '/set\", \"state_topic\": \"' + flow.get(\"StateSetPrefix\") + '/switch/power/' + name + '/state\", \"unique_id\": \"'+ id + '_power\"}'\n node.send(switchmsg);\n }\n \n //Setpoint \n if (flow.get(\"CreateSetpoint\") == true)\n {\n //switchmsg.retain = true\n switchmsg.topic = flow.get(\"AutoDiscoveryPrefix\") + '/climate/setpoint/' + name + '/config'\n switchmsg.payload = '{\"name\": \"Daikin ' + name + ' Setpoint\", \"temperature_command_topic\":\"' + flow.get(\"StateSetPrefix\") + '/climate/setpoint/' + name + '/targetTempCmd\", \"temperature_state_topic\":\"' + flow.get(\"StateSetPrefix\") + '/climate/setpoint/' + name + '/state\",\"unique_id\": \"'+ id + '_setpoint\"}'\n node.send(switchmsg);\n }\n \n //Mode\n if (flow.get(\"CreateMode\") == true)\n {\n //switchmsg.retain = true\n switchmsg.topic = flow.get(\"AutoDiscoveryPrefix\") + '/select/mode/' + name + '/config'\n switchmsg.payload = '{\"name\": \"Daikin ' + name + ' Mode\", \"command_topic\": \"' + flow.get(\"StateSetPrefix\") + '/select/mode/' + name + '/set\", \"state_topic\": \"' + flow.get(\"StateSetPrefix\") + '/select/mode/' + name + '/state\", \"options\": [\"off\", \"auto\", \"cooling\", \"heating\", \"fanOnly\", \"dry\"] , \"unique_id\": \"'+ id + '_mode\"}'\n node.send(switchmsg);\n }\n \n //FanDirection\n if (flow.get(\"CreateFanDirection\") == true)\n {\n //switchmsg.retain = true\n switchmsg.topic = flow.get(\"AutoDiscoveryPrefix\") + '/select/fandirection/' + name + '/config'\n switchmsg.payload = '{\"name\": \"Daikin ' + name + ' Fan Direction\", \"command_topic\": \"' + flow.get(\"StateSetPrefix\") + '/select/fandirection/' + name + '/set\", \"state_topic\": \"' + flow.get(\"StateSetPrefix\") + '/select/fandirection/' + name + '/state\", \"options\": [\"Off\", \"Horizontal\", \"Vertical\", \"3D-Swing\"] , \"unique_id\": \"'+ id + '_fandirection\"}'\n node.send(switchmsg);\n }\n \n //FanSpeed\n if (flow.get(\"CreateFanSpeed\") == true)\n {\n //switchmsg.retain = true\n switchmsg.topic = flow.get(\"AutoDiscoveryPrefix\") + '/select/fanspeed/' + name + '/config'\n switchmsg.payload = '{\"name\": \"Daikin ' + name + ' Fan Speed\", \"command_topic\": \"' + flow.get(\"StateSetPrefix\") + '/select/fanspeed/' + name + '/set\", \"state_topic\": \"' + flow.get(\"StateSetPrefix\") + '/select/fanspeed/' + name + '/state\", \"options\": [\"Off\", \"Level 1\", \"Level 2\", \"Level 3\", \"Level 4\", \"Level 5\", \"Auto\", \"Quiet\"] , \"unique_id\": \"'+ id + '_fanspeed\"}'\n node.send(switchmsg);\n }\n \n //Powerful\n if (flow.get(\"CreatePowerful\") == true)\n {\n //switchmsg.retain = true\n switchmsg.topic = flow.get(\"AutoDiscoveryPrefix\") + '/switch/powerful/' + name + '/config'\n switchmsg.payload = '{\"name\": \"Daikin ' + name + ' Powerful\", \"command_topic\": \"' + flow.get(\"StateSetPrefix\") + '/switch/powerful/' + name + '/set\", \"state_topic\": \"' + flow.get(\"StateSetPrefix\") + '/switch/powerful/' + name + '/state\", \"unique_id\": \"'+ id + '_powerful\"}'\n node.send(switchmsg);\n }\n \n //Econo\n if (flow.get(\"CreateEcono\") == true)\n {\n //switchmsg.retain = true\n switchmsg.topic = flow.get(\"AutoDiscoveryPrefix\") + '/switch/econo/' + name + '/config'\n switchmsg.payload = '{\"name\": \"Daikin ' + name + ' Econo\", \"command_topic\": \"' + flow.get(\"StateSetPrefix\") + '/switch/econo/' + name + '/set\", \"state_topic\": \"' + flow.get(\"StateSetPrefix\") + '/switch/econo/' + name + '/state\", \"unique_id\": \"'+ id + '_econo\"}'\n node.send(switchmsg);\n } \n \n //LED\n if (flow.get(\"CreateLed\") == true)\n {\n //switchmsg.retain = true\n switchmsg.topic = flow.get(\"AutoDiscoveryPrefix\") + '/switch/led/' + name + '/config'\n switchmsg.payload = '{\"name\": \"Daikin ' + name + ' Led\", \"command_topic\": \"daikin/switch/led/' + name + '/set\", \"state_topic\": \"daikin/switch/led/' + name + '/state\", \"unique_id\": \"'+ id + '_led\"}'\n node.send(switchmsg);\n }\n \n //Indoor Temperature\n if (flow.get(\"CreateIndoorTemperature\") == true)\n {\n //switchmsg.retain = true\n switchmsg.topic = flow.get(\"AutoDiscoveryPrefix\") + '/sensor/indoor_temp/' + name + '/config'\n switchmsg.payload = '{\"name\": \"Daikin ' + name + ' Indoor Temp\", \"device_class\": \"temperature\", \"state_topic\":\"' + flow.get(\"StateSetPrefix\") + '/sensor/indoor_temp/' + name + '/state\",\"unit_of_measurement\": \"°C\", \"value_template\": \"{{ value_json.temperature}}\", \"unique_id\": \"'+ id + '_indoor_temp\"}'\n node.send(switchmsg);\n }\n \n //Outdoor Temperature\n if (flow.get(\"CreateOutdoorTemperature\") == true)\n {\n //switchmsg.retain = true\n switchmsg.topic = flow.get(\"AutoDiscoveryPrefix\") + '/sensor/outdoor_temp/' + name + '/config'\n switchmsg.payload = '{\"name\": \"Daikin ' + name + ' Outdoor Temp\", \"device_class\": \"temperature\", \"state_topic\":\"' + flow.get(\"StateSetPrefix\") + '/sensor/outdoor_temp/' + name + '/state\",\"unit_of_measurement\": \"°C\", \"value_template\": \"{{ value_json.temperature}}\", \"unique_id\": \"'+ id + '_outdoor_temp\"}'\n node.send(switchmsg);\n }\n \n //KWH COOL\n if (flow.get(\"CreatekWhCool\") == true)\n {\n //switchmsg.retain = true\n switchmsg.topic = flow.get(\"AutoDiscoveryPrefix\") + '/sensor/kwh_cool/' + name + '/config'\n switchmsg.payload = '{\"name\": \"Daikin ' + name + ' kWh Cool\", \"device_class\": \"total\", \"state_topic\":\"' + flow.get(\"StateSetPrefix\") + '/sensor/kwh_cool/' + name + '/state\",\"unit_of_measurement\": \"kwh\", \"unique_id\": \"'+ id + '_kwh_cool\"}'\n node.send(switchmsg);\n }\n \n //KWH HEAT\n if (flow.get(\"CreatekWhHeat\") == true)\n {\n //switchmsg.retain = true\n switchmsg.topic = flow.get(\"AutoDiscoveryPrefix\") + '/sensor/kwh_heat/' + name + '/config'\n switchmsg.payload = '{\"name\": \"Daikin ' + name + ' kWh Heat\", \"device_class\": \"total\", \"state_topic\":\"' + flow.get(\"StateSetPrefix\") + '/sensor/kwh_heat/' + name + '/state\",\"unit_of_measurement\": \"kwh\", \"unique_id\": \"'+ id + '_kwh_heat\"}'\n node.send(switchmsg);\n }\n \n //KWH TOTAL\n if (flow.get(\"CreatekWhTotal\") == true)\n {\n //switchmsg.retain = true\n switchmsg.topic = flow.get(\"AutoDiscoveryPrefix\") + '/sensor/kwh_total/' + name + '/config'\n switchmsg.payload = '{\"name\": \"Daikin ' + name + ' kWh Total\", \"device_class\": \"total\", \"state_topic\":\"' + flow.get(\"StateSetPrefix\") + '/sensor/kwh_total/' + name + '/state\",\"unit_of_measurement\": \"kwh\", \"unique_id\": \"'+ id + '_kwh_total\"}'\n node.send(switchmsg);\n }\n \n }",
  1057. "outputs": 1,
  1058. "noerr": 0,
  1059. "initialize": "",
  1060. "finalize": "",
  1061. "libs": [],
  1062. "x": 1140,
  1063. "y": 360,
  1064. "wires": [
  1065. [
  1066. "fb0819061dac9a48"
  1067. ]
  1068. ]
  1069. },
  1070. {
  1071. "id": "545311eec9d6a0b6",
  1072. "type": "comment",
  1073. "z": "6d2f931c87bbb1a0",
  1074. "name": "Step 3: Enable flow",
  1075. "info": "Go back to the dashboard (CTRL+SHIFT+D) and enable start flow and save settings.",
  1076. "x": 650,
  1077. "y": 20,
  1078. "wires": []
  1079. },
  1080. {
  1081. "id": "886993245976a21b",
  1082. "type": "catch",
  1083. "z": "6d2f931c87bbb1a0",
  1084. "name": "",
  1085. "scope": [
  1086. "b0aff63096645ac2",
  1087. "26ce01afe0babef8",
  1088. "7a07e52fc7e0fd6e"
  1089. ],
  1090. "uncaught": false,
  1091. "x": 110,
  1092. "y": 200,
  1093. "wires": [
  1094. [
  1095. "b214611f83bf3afe"
  1096. ]
  1097. ]
  1098. },
  1099. {
  1100. "id": "b214611f83bf3afe",
  1101. "type": "function",
  1102. "z": "6d2f931c87bbb1a0",
  1103. "name": "function 1",
  1104. "func": "var str = msg.error.message\nmsg.filename = str.split(\"'\")[1]\nreturn msg;",
  1105. "outputs": 1,
  1106. "noerr": 0,
  1107. "initialize": "",
  1108. "finalize": "",
  1109. "libs": [],
  1110. "x": 240,
  1111. "y": 200,
  1112. "wires": [
  1113. [
  1114. "d0df01c30e16d3f0"
  1115. ]
  1116. ]
  1117. },
  1118. {
  1119. "id": "d0df01c30e16d3f0",
  1120. "type": "file",
  1121. "z": "6d2f931c87bbb1a0",
  1122. "name": "",
  1123. "filename": "filename",
  1124. "filenameType": "msg",
  1125. "appendNewline": false,
  1126. "createDir": true,
  1127. "overwriteFile": "false",
  1128. "encoding": "none",
  1129. "x": 380,
  1130. "y": 200,
  1131. "wires": [
  1132. []
  1133. ]
  1134. },
  1135. {
  1136. "id": "42bc4e80deb9162e",
  1137. "type": "mqtt-broker",
  1138. "name": "",
  1139. "broker": "127.0.0.1",
  1140. "port": "1883",
  1141. "clientid": "",
  1142. "autoConnect": false,
  1143. "usetls": false,
  1144. "protocolVersion": "4",
  1145. "keepalive": "60",
  1146. "cleansession": true,
  1147. "birthTopic": "",
  1148. "birthQos": "0",
  1149. "birthPayload": "",
  1150. "birthMsg": {},
  1151. "closeTopic": "",
  1152. "closeQos": "0",
  1153. "closePayload": "",
  1154. "closeMsg": {},
  1155. "willTopic": "",
  1156. "willQos": "0",
  1157. "willPayload": "",
  1158. "willMsg": {},
  1159. "sessionExpiry": ""
  1160. },
  1161. {
  1162. "id": "a06bad650164a668",
  1163. "type": "ui_group",
  1164. "name": "MQTT AutoDiscovery Settings",
  1165. "tab": "80f27d37af33d82b",
  1166. "order": 2,
  1167. "disp": true,
  1168. "width": "12",
  1169. "collapse": false,
  1170. "className": ""
  1171. },
  1172. {
  1173. "id": "43745523810d126b",
  1174. "type": "ui_group",
  1175. "name": "General Settings",
  1176. "tab": "80f27d37af33d82b",
  1177. "order": 1,
  1178. "disp": true,
  1179. "width": "6",
  1180. "collapse": false,
  1181. "className": ""
  1182. },
  1183. {
  1184. "id": "80f27d37af33d82b",
  1185. "type": "ui_tab",
  1186. "name": "Daikin Cloud",
  1187. "icon": "dashboard",
  1188. "disabled": false,
  1189. "hidden": false
  1190. }
  1191. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement