Advertisement
pokornymartin

bulb_zigbee

Mar 15th, 2021
96
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [
  2. {
  3. "id": "7cc13ada.b6712c",
  4. "type": "subflow",
  5. "name": "timerange",
  6. "info": "Lets through or blocks a payload\nbased on a time range. This can\neither be configured through the\nenviroment variables in the node ui\nor as described below with a message\nthat has an override topic.\nIf in range the msg will be passed\nto the first output and otherwise\nto the second.\nThe start and stop time needs\nto be defined in an hh:mm format.\nThere is also a week array. The week\nstarts on monday so 4 for example is\nThursday. Payload will only be passed\non days that are in the array.\nOut of time range payloads will\nbe redirected to the second output.\nThe schedule can be overriden by injecting\na message with the topic of \"override\"\nthat contains a ```msg.payload``` object with the\nkeys of \"start\",\"stop\",\"days\" like\nthis:\n```\n{\n \"start\": \"10:00\",\n \"stop\": \"14:00\",\n \"days\": [\n 1,\n 2,\n 3,\n 4,\n 5,\n 6,\n 7\n ]\n}\n```\nStart and stop need to be strings in the hh:mm\nformat and days an array of numbers as\ndescribed above.\nThe override can be deleted by injecting a\nmsg.payload string \"reset\".",
  7. "category": "",
  8. "in": [
  9. {
  10. "x": 100,
  11. "y": 100,
  12. "wires": [
  13. {
  14. "id": "da7f7d3f.da5af"
  15. }
  16. ]
  17. }
  18. ],
  19. "out": [
  20. {
  21. "x": 620,
  22. "y": 60,
  23. "wires": [
  24. {
  25. "id": "694ce0e1.4bee58",
  26. "port": 0
  27. }
  28. ]
  29. },
  30. {
  31. "x": 620,
  32. "y": 140,
  33. "wires": [
  34. {
  35. "id": "694ce0e1.4bee58",
  36. "port": 1
  37. }
  38. ]
  39. }
  40. ],
  41. "env": [
  42. {
  43. "name": "start",
  44. "type": "str",
  45. "value": "00:00",
  46. "ui": {
  47. "icon": "font-awesome/fa-arrow-right",
  48. "label": {
  49. "en-US": "from hh:mm"
  50. },
  51. "type": "input",
  52. "opts": {
  53. "types": [
  54. "str"
  55. ]
  56. }
  57. }
  58. },
  59. {
  60. "name": "stop",
  61. "type": "str",
  62. "value": "00:00",
  63. "ui": {
  64. "icon": "font-awesome/fa-circle",
  65. "label": {
  66. "en-US": "until hh:mm"
  67. },
  68. "type": "input",
  69. "opts": {
  70. "types": [
  71. "str"
  72. ]
  73. }
  74. }
  75. },
  76. {
  77. "name": "days",
  78. "type": "json",
  79. "value": "[1,2,3,4,5,6,7]",
  80. "ui": {
  81. "icon": "font-awesome/fa-calendar",
  82. "label": {
  83. "en-US": "days"
  84. },
  85. "type": "input",
  86. "opts": {
  87. "types": [
  88. "json"
  89. ]
  90. }
  91. }
  92. }
  93. ],
  94. "color": "#C7E9C0",
  95. "inputLabels": [
  96. "payload input"
  97. ],
  98. "outputLabels": [
  99. "in time range",
  100. "out of time range"
  101. ],
  102. "icon": "node-red/switch.svg",
  103. "status": {
  104. "x": 480,
  105. "y": 200,
  106. "wires": [
  107. {
  108. "id": "1bc56c04.ca0a3c",
  109. "port": 0
  110. }
  111. ]
  112. }
  113. },
  114. {
  115. "id": "694ce0e1.4bee58",
  116. "type": "function",
  117. "z": "7cc13ada.b6712c",
  118. "name": "is in range?",
  119. "func": "const schedule = flow.get(\"schedule\");\nlet start = env.get(\"start\");\nlet stop = env.get(\"stop\");\nlet days = env.get(\"days\");\nif(schedule !== undefined){\n start = schedule.start;\n stop = schedule.stop;\n days = schedule.days;\n}\nconst time = new Date();\nlet day = time.getDay();\nif(day === 0) day = 7;\nlet hour = String(time.getHours());\nlet minute = String(time.getMinutes());\nif(hour.length == 1) hour = \"0\" + hour;\nif(minute.length == 1) minute = \"0\" + minute;\nconst hmtime = hour + \":\" + minute;\nif(days.includes(day)){\n if(start == stop){\n return [msg, null];\n } else if(start > stop){\n if(hmtime >= start || hmtime < stop){\n return [msg, null];\n } else {\n return [null, msg];\n }\n } else if(hmtime >= start && hmtime < stop){\n return [msg, null];\n } else {\n return [null, msg];\n }\n} else {\n return null;\n}",
  120. "outputs": 2,
  121. "noerr": 0,
  122. "x": 450,
  123. "y": 100,
  124. "wires": [
  125. [],
  126. []
  127. ]
  128. },
  129. {
  130. "id": "94dc9c00.0f576",
  131. "type": "inject",
  132. "z": "7cc13ada.b6712c",
  133. "name": "",
  134. "repeat": "",
  135. "crontab": "",
  136. "once": true,
  137. "onceDelay": 0.1,
  138. "topic": "",
  139. "payload": "",
  140. "payloadType": "date",
  141. "x": 170,
  142. "y": 200,
  143. "wires": [
  144. [
  145. "1bc56c04.ca0a3c"
  146. ]
  147. ]
  148. },
  149. {
  150. "id": "1bc56c04.ca0a3c",
  151. "type": "function",
  152. "z": "7cc13ada.b6712c",
  153. "name": "display rule",
  154. "func": "const schedule = flow.get(\"schedule\");\nif(typeof schedule == \"object\"){\n const start = schedule.start;\n const stop = schedule.stop;\n const days = String(schedule.days).replace(/1/g,\"Mo\").replace(/2/g,\"Tu\").replace(/3/g,\"We\").replace(/4/g,\"Th\").replace(/5/g,\"Fr\").replace(/6/g,\"Sa\").replace(/7/g,\"Su\");\n msg.payload = \"override: \" + start + \"-\" + stop + \"/\" + days;\n} else {\n const start = env.get(\"start\");\n const stop = env.get(\"stop\");\n const days = String(env.get(\"days\")).replace(/1/g,\"Mo\").replace(/2/g,\"Tu\").replace(/3/g,\"We\").replace(/4/g,\"Th\").replace(/5/g,\"Fr\").replace(/6/g,\"Sa\").replace(/7/g,\"Su\");\n const override = false;\n msg.payload = start + \"-\" + stop + \"/\" + days;\n}\nreturn msg;",
  155. "outputs": 1,
  156. "noerr": 0,
  157. "x": 350,
  158. "y": 200,
  159. "wires": [
  160. []
  161. ]
  162. },
  163. {
  164. "id": "da7f7d3f.da5af",
  165. "type": "function",
  166. "z": "7cc13ada.b6712c",
  167. "name": "check for override",
  168. "func": "if(msg.topic == \"override\"){\n flow.set(\"schedule\",msg.payload);\n return [null, msg];\n} else if (msg.payload == \"reset\"){\n let reset;\n flow.set(\"schedule\",reset);\n return [null, msg];\n} else {\n return [msg, null];\n}",
  169. "outputs": 2,
  170. "noerr": 0,
  171. "x": 250,
  172. "y": 100,
  173. "wires": [
  174. [
  175. "694ce0e1.4bee58"
  176. ],
  177. [
  178. "1bc56c04.ca0a3c"
  179. ]
  180. ]
  181. },
  182. {
  183. "id": "af1181be.d4eac",
  184. "type": "mqtt out",
  185. "z": "a144872e.0e8648",
  186. "name": "",
  187. "topic": "zigbee2mqtt/XIAOMI_bulb_1/set",
  188. "qos": "",
  189. "retain": "",
  190. "broker": "9b45018.62024",
  191. "x": 1490,
  192. "y": 400,
  193. "wires": []
  194. },
  195. {
  196. "id": "6bd7677a.d95ce8",
  197. "type": "json",
  198. "z": "a144872e.0e8648",
  199. "name": "",
  200. "x": 350,
  201. "y": 420,
  202. "wires": [
  203. [
  204. "46dae304.f1f48c"
  205. ]
  206. ]
  207. },
  208. {
  209. "id": "46dae304.f1f48c",
  210. "type": "contrib-json",
  211. "z": "a144872e.0e8648",
  212. "engine": "JSONPath",
  213. "command": "jq",
  214. "expr": "$..occupancy",
  215. "complete": "property",
  216. "prop": "payload",
  217. "name": "Get state",
  218. "x": 480,
  219. "y": 420,
  220. "wires": [
  221. [
  222. "6cd47f7f.09f2b"
  223. ]
  224. ]
  225. },
  226. {
  227. "id": "82fa0960.6c3d58",
  228. "type": "change",
  229. "z": "a144872e.0e8648",
  230. "name": "nizká intenzita svetla",
  231. "rules": [
  232. {
  233. "t": "set",
  234. "p": "payload",
  235. "pt": "msg",
  236. "to": "{\"state\":\"ON\",\"brightness\":50,\"color_temp\":255}",
  237. "tot": "str"
  238. }
  239. ],
  240. "action": "",
  241. "property": "",
  242. "from": "",
  243. "to": "",
  244. "reg": false,
  245. "x": 1180,
  246. "y": 320,
  247. "wires": [
  248. [
  249. "af1181be.d4eac"
  250. ]
  251. ]
  252. },
  253. {
  254. "id": "6336f85.219c608",
  255. "type": "switch",
  256. "z": "a144872e.0e8648",
  257. "name": "",
  258. "property": "payload",
  259. "propertyType": "msg",
  260. "rules": [
  261. {
  262. "t": "true"
  263. },
  264. {
  265. "t": "false"
  266. }
  267. ],
  268. "checkall": "true",
  269. "repair": false,
  270. "outputs": 2,
  271. "x": 750,
  272. "y": 420,
  273. "wires": [
  274. [
  275. "42ca7bf8.41bae4",
  276. "768c4860.c904c8"
  277. ],
  278. []
  279. ]
  280. },
  281. {
  282. "id": "d5dc1aa2.54a018",
  283. "type": "change",
  284. "z": "a144872e.0e8648",
  285. "name": "",
  286. "rules": [
  287. {
  288. "t": "set",
  289. "p": "payload",
  290. "pt": "msg",
  291. "to": "{\"state\":\"OFF\",\"brightness\":100,\"color_temp\":80}",
  292. "tot": "str"
  293. }
  294. ],
  295. "action": "",
  296. "property": "",
  297. "from": "",
  298. "to": "",
  299. "reg": false,
  300. "x": 1180,
  301. "y": 480,
  302. "wires": [
  303. [
  304. "af1181be.d4eac"
  305. ]
  306. ]
  307. },
  308. {
  309. "id": "6cd47f7f.09f2b",
  310. "type": "splitter",
  311. "z": "a144872e.0e8648",
  312. "name": "Split array",
  313. "property": "payload",
  314. "x": 620,
  315. "y": 420,
  316. "wires": [
  317. [
  318. "6336f85.219c608"
  319. ]
  320. ]
  321. },
  322. {
  323. "id": "42ca7bf8.41bae4",
  324. "type": "countdown",
  325. "z": "a144872e.0e8648",
  326. "name": "",
  327. "topic": "",
  328. "payloadTimerStart": "false",
  329. "payloadTimerStartType": "bool",
  330. "payloadTimerStop": "true",
  331. "payloadTimerStopType": "bool",
  332. "timer": "60",
  333. "resetWhileRunning": true,
  334. "setTimeToNewWhileRunning": true,
  335. "startCountdownOnControlMessage": false,
  336. "x": 890,
  337. "y": 460,
  338. "wires": [
  339. [],
  340. [
  341. "459d855.8b3da7c"
  342. ]
  343. ]
  344. },
  345. {
  346. "id": "459d855.8b3da7c",
  347. "type": "switch",
  348. "z": "a144872e.0e8648",
  349. "name": "",
  350. "property": "payload",
  351. "propertyType": "msg",
  352. "rules": [
  353. {
  354. "t": "eq",
  355. "v": "1",
  356. "vt": "num"
  357. }
  358. ],
  359. "checkall": "true",
  360. "repair": false,
  361. "outputs": 1,
  362. "x": 1030,
  363. "y": 480,
  364. "wires": [
  365. [
  366. "d5dc1aa2.54a018"
  367. ]
  368. ]
  369. },
  370. {
  371. "id": "768c4860.c904c8",
  372. "type": "subflow:7cc13ada.b6712c",
  373. "z": "a144872e.0e8648",
  374. "name": "22-8",
  375. "env": [
  376. {
  377. "name": "start",
  378. "value": "22:00",
  379. "type": "str"
  380. },
  381. {
  382. "name": "stop",
  383. "value": "08:00",
  384. "type": "str"
  385. }
  386. ],
  387. "x": 870,
  388. "y": 360,
  389. "wires": [
  390. [
  391. "82fa0960.6c3d58"
  392. ],
  393. [
  394. "8ed366e2.8df208"
  395. ]
  396. ]
  397. },
  398. {
  399. "id": "895133f7.7fe43",
  400. "type": "change",
  401. "z": "a144872e.0e8648",
  402. "name": "svítí méně",
  403. "rules": [
  404. {
  405. "t": "set",
  406. "p": "payload",
  407. "pt": "msg",
  408. "to": "{\"state\":\"ON\",\"brightness\":100,\"color_temp\":50}",
  409. "tot": "str"
  410. }
  411. ],
  412. "action": "",
  413. "property": "",
  414. "from": "",
  415. "to": "",
  416. "reg": false,
  417. "x": 1170,
  418. "y": 360,
  419. "wires": [
  420. [
  421. "af1181be.d4eac"
  422. ]
  423. ]
  424. },
  425. {
  426. "id": "8ed366e2.8df208",
  427. "type": "subflow:7cc13ada.b6712c",
  428. "z": "a144872e.0e8648",
  429. "name": "17-22",
  430. "env": [
  431. {
  432. "name": "start",
  433. "value": "17:00",
  434. "type": "str"
  435. },
  436. {
  437. "name": "stop",
  438. "value": "22:00",
  439. "type": "str"
  440. }
  441. ],
  442. "x": 1010,
  443. "y": 380,
  444. "wires": [
  445. [
  446. "895133f7.7fe43"
  447. ],
  448. [
  449. "e5b5bfc4.8a1ca"
  450. ]
  451. ]
  452. },
  453. {
  454. "id": "e5b5bfc4.8a1ca",
  455. "type": "change",
  456. "z": "a144872e.0e8648",
  457. "name": "svítí naplno",
  458. "rules": [
  459. {
  460. "t": "set",
  461. "p": "payload",
  462. "pt": "msg",
  463. "to": "{\"state\":\"ON\",\"brightness\":255,\"color_temp\":50}",
  464. "tot": "str"
  465. }
  466. ],
  467. "action": "",
  468. "property": "",
  469. "from": "",
  470. "to": "",
  471. "reg": false,
  472. "x": 1190,
  473. "y": 400,
  474. "wires": [
  475. [
  476. "af1181be.d4eac"
  477. ]
  478. ]
  479. },
  480. {
  481. "id": "891d3bc5.6e9198",
  482. "type": "mqtt in",
  483. "z": "a144872e.0e8648",
  484. "name": "",
  485. "topic": "zigbee2mqtt/XIAOMI_move_1",
  486. "qos": "2",
  487. "datatype": "auto",
  488. "broker": "9b45018.62024",
  489. "x": 140,
  490. "y": 360,
  491. "wires": [
  492. [
  493. "6bd7677a.d95ce8"
  494. ]
  495. ]
  496. },
  497. {
  498. "id": "dfc45e1d.94cd7",
  499. "type": "mqtt in",
  500. "z": "a144872e.0e8648",
  501. "name": "",
  502. "topic": "zigbee2mqtt/XIAOMI_move_2",
  503. "qos": "2",
  504. "datatype": "auto",
  505. "broker": "9b45018.62024",
  506. "x": 140,
  507. "y": 460,
  508. "wires": [
  509. [
  510. "6bd7677a.d95ce8"
  511. ]
  512. ]
  513. },
  514. {
  515. "id": "9b45018.62024",
  516. "type": "mqtt-broker",
  517. "name": "",
  518. "broker": "",
  519. "port": "",
  520. "tls": "",
  521. "clientid": "",
  522. "usetls": false,
  523. "compatmode": true,
  524. "keepalive": "15",
  525. "cleansession": true,
  526. "birthTopic": "",
  527. "birthQos": "0",
  528. "birthPayload": "",
  529. "closeTopic": "",
  530. "closePayload": "",
  531. "willTopic": "",
  532. "willQos": "0",
  533. "willPayload": ""
  534. },
  535. {
  536. "id": "",
  537. "type": "tls-config",
  538. "name": "",
  539. "cert": "",
  540. "key": "",
  541. "ca": "",
  542. "certname": "m2mqtt_srv.crt",
  543. "keyname": "m2mqtt_srv.key",
  544. "caname": "m2mqtt_ca.crt",
  545. "servername": "",
  546. "verifyservercert": false
  547. }
  548. ]
Advertisement
RAW Paste Data Copied
Advertisement