Guest User

Untitled

a guest
Dec 13th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.01 KB | None | 0 0
  1. [
  2. {
  3. "id": "194463a7.c501ac",
  4. "type": "subflow",
  5. "name": "Who is home?",
  6. "info": "",
  7. "in": [
  8. {
  9. "x": 60,
  10. "y": 60,
  11. "wires": [
  12. {
  13. "id": "c19c61b3.2a33f"
  14. }
  15. ]
  16. }
  17. ],
  18. "out": [
  19. {
  20. "x": 1120,
  21. "y": 60,
  22. "wires": [
  23. {
  24. "id": "8ee27d68.fe90b",
  25. "port": 0
  26. }
  27. ]
  28. }
  29. ]
  30. },
  31. {
  32. "id": "b4a281ad.7b804",
  33. "type": "join",
  34. "z": "194463a7.c501ac",
  35. "name": "",
  36. "mode": "custom",
  37. "build": "merged",
  38. "property": "payload",
  39. "propertyType": "msg",
  40. "key": "topic",
  41. "joiner": "\\n",
  42. "joinerType": "str",
  43. "accumulate": false,
  44. "timeout": "",
  45. "count": "2",
  46. "reduceRight": false,
  47. "reduceExp": "",
  48. "reduceInit": "",
  49. "reduceInitType": "",
  50. "reduceFixup": "",
  51. "x": 770,
  52. "y": 60,
  53. "wires": [
  54. [
  55. "8ee27d68.fe90b"
  56. ]
  57. ]
  58. },
  59. {
  60. "id": "8ee27d68.fe90b",
  61. "type": "function",
  62. "z": "194463a7.c501ac",
  63. "name": "set telegram service",
  64. "func": "var service;\nif(msg.payload.user1 === \"home\" && msg.payload.user2 === \"home\"){\n service = \"telegram\";\n}\nelse if(msg.payload.user1 === \"home\"){\n service = \"telegram_user1\";\n}\nelse if(msg.payload.user2 === \"home\"){\n service = \"telegram_user2\";\n}\nelse{\n service = \"telegram\";\n}\nreturn {\"payload\":{\"service\":service}};",
  65. "outputs": 1,
  66. "noerr": 0,
  67. "x": 960,
  68. "y": 60,
  69. "wires": [
  70. []
  71. ]
  72. },
  73. {
  74. "id": "5d334d00.300524",
  75. "type": "api-get-history",
  76. "z": "194463a7.c501ac",
  77. "name": "get history user1",
  78. "server": "aac717d.c0c40e8",
  79. "startdate": "",
  80. "enddate": "",
  81. "entityid": "sensor.user1_status",
  82. "entityidtype": "includes",
  83. "x": 440,
  84. "y": 40,
  85. "wires": [
  86. [
  87. "66fd5763.b6e3b8"
  88. ]
  89. ]
  90. },
  91. {
  92. "id": "2572b25e.f3ef8e",
  93. "type": "api-get-history",
  94. "z": "194463a7.c501ac",
  95. "name": "get history user2",
  96. "server": "aac717d.c0c40e8",
  97. "startdate": "",
  98. "enddate": "",
  99. "entityid": "sensor.sebastian_status",
  100. "entityidtype": "includes",
  101. "x": 440,
  102. "y": 80,
  103. "wires": [
  104. [
  105. "c792d038.75f7b"
  106. ]
  107. ]
  108. },
  109. {
  110. "id": "c19c61b3.2a33f",
  111. "type": "moment",
  112. "z": "194463a7.c501ac",
  113. "name": "-15 min as startdate",
  114. "topic": "",
  115. "input": "",
  116. "inputType": "date",
  117. "inTz": "Etc/UTC",
  118. "adjAmount": "15",
  119. "adjType": "minutes",
  120. "adjDir": "subtract",
  121. "format": "",
  122. "locale": "POSIX",
  123. "output": "startdate",
  124. "outputType": "msg",
  125. "outTz": "Etc/UTC",
  126. "x": 220,
  127. "y": 60,
  128. "wires": [
  129. [
  130. "2572b25e.f3ef8e",
  131. "5d334d00.300524"
  132. ]
  133. ]
  134. },
  135. {
  136. "id": "66fd5763.b6e3b8",
  137. "type": "function",
  138. "z": "194463a7.c501ac",
  139. "name": "set user1",
  140. "func": "var home = msg.payload[0].some(function(el) {\n return el.state === \"home\";\n});\nreturn {\"payload\":{\"user1\":home?\"home\":\"away\"}};",
  141. "outputs": 1,
  142. "noerr": 0,
  143. "x": 620,
  144. "y": 40,
  145. "wires": [
  146. [
  147. "b4a281ad.7b804"
  148. ]
  149. ]
  150. },
  151. {
  152. "id": "c792d038.75f7b",
  153. "type": "function",
  154. "z": "194463a7.c501ac",
  155. "name": "set user2",
  156. "func": "var home = msg.payload[0].some(function(el) {\n return el.state === \"home\";\n});\nreturn {\"payload\":{\"user2\":home?\"home\":\"away\"}};",
  157. "outputs": 1,
  158. "noerr": 0,
  159. "x": 620,
  160. "y": 80,
  161. "wires": [
  162. [
  163. "b4a281ad.7b804"
  164. ]
  165. ]
  166. },
  167. {
  168. "id": "557cc62.b2a3638",
  169. "type": "switch",
  170. "z": "27a36387.d08f7c",
  171. "name": "was < 1500 before",
  172. "property": "$number(data.old_state.state)",
  173. "propertyType": "jsonata",
  174. "rules": [
  175. {
  176. "t": "lt",
  177. "v": "1500",
  178. "vt": "num"
  179. },
  180. {
  181. "t": "gte",
  182. "v": "1500",
  183. "vt": "num"
  184. }
  185. ],
  186. "checkall": "true",
  187. "repair": false,
  188. "outputs": 2,
  189. "x": 310,
  190. "y": 1040,
  191. "wires": [
  192. [
  193. "ef7f2fa0.deaf8"
  194. ],
  195. [
  196. "29183b1.7f300c4"
  197. ]
  198. ]
  199. },
  200. {
  201. "id": "22b2b366.d4ca5c",
  202. "type": "api-call-service",
  203. "z": "27a36387.d08f7c",
  204. "name": "co2 above 2000",
  205. "server": "aac717d.c0c40e8",
  206. "service_domain": "notify",
  207. "service": "",
  208. "data": "{ \"message\": \"Der CO₂-Wert ist über 2000ppm. Lebt ihr noch?\", \"data\": {\"inline_keyboard\":[\"Ja ich habe überlebt!:/still_alive\"]} }",
  209. "mergecontext": "",
  210. "x": 1100,
  211. "y": 1060,
  212. "wires": [
  213. []
  214. ]
  215. },
  216. {
  217. "id": "25dd1c10.12a8e4",
  218. "type": "api-call-service",
  219. "z": "27a36387.d08f7c",
  220. "name": "co2 above 1500",
  221. "server": "aac717d.c0c40e8",
  222. "service_domain": "notify",
  223. "service": "",
  224. "data": "{ \"message\": \"Der CO₂-Wert ist über 1500ppm. Bitte lüften!\" }",
  225. "mergecontext": "",
  226. "x": 880,
  227. "y": 1020,
  228. "wires": [
  229. []
  230. ]
  231. },
  232. {
  233. "id": "ef7f2fa0.deaf8",
  234. "type": "switch",
  235. "z": "27a36387.d08f7c",
  236. "name": "co2 is now >= 1500",
  237. "property": "$number(payload)",
  238. "propertyType": "jsonata",
  239. "rules": [
  240. {
  241. "t": "gte",
  242. "v": "1500",
  243. "vt": "num"
  244. }
  245. ],
  246. "checkall": "true",
  247. "repair": false,
  248. "outputs": 1,
  249. "x": 530,
  250. "y": 1020,
  251. "wires": [
  252. [
  253. "4fcbf9b0.9fc458"
  254. ]
  255. ]
  256. },
  257. {
  258. "id": "4b8c38f7.c1e408",
  259. "type": "switch",
  260. "z": "27a36387.d08f7c",
  261. "name": "co2 is now >= 2000",
  262. "property": "$number(payload)",
  263. "propertyType": "jsonata",
  264. "rules": [
  265. {
  266. "t": "gte",
  267. "v": "2000",
  268. "vt": "num"
  269. }
  270. ],
  271. "checkall": "true",
  272. "repair": false,
  273. "outputs": 1,
  274. "x": 750,
  275. "y": 1060,
  276. "wires": [
  277. [
  278. "388342b4.36d97e"
  279. ]
  280. ]
  281. },
  282. {
  283. "id": "29183b1.7f300c4",
  284. "type": "switch",
  285. "z": "27a36387.d08f7c",
  286. "name": "co2 was < 2000 before",
  287. "property": "$number(data.old_state.state)",
  288. "propertyType": "jsonata",
  289. "rules": [
  290. {
  291. "t": "lt",
  292. "v": "2000",
  293. "vt": "num"
  294. }
  295. ],
  296. "checkall": "true",
  297. "repair": false,
  298. "outputs": 1,
  299. "x": 540,
  300. "y": 1060,
  301. "wires": [
  302. [
  303. "4b8c38f7.c1e408"
  304. ]
  305. ]
  306. },
  307. {
  308. "id": "b08b59ed.c27e38",
  309. "type": "server-state-changed",
  310. "z": "27a36387.d08f7c",
  311. "name": "Living room CO2",
  312. "server": "aac717d.c0c40e8",
  313. "entityidfilter": "sensor.netatmo_indoor_co2",
  314. "entityidfiltertype": "exact",
  315. "haltifstate": "",
  316. "x": 100,
  317. "y": 1040,
  318. "wires": [
  319. [
  320. "557cc62.b2a3638"
  321. ]
  322. ]
  323. },
  324. {
  325. "id": "388342b4.36d97e",
  326. "type": "subflow:194463a7.c501ac",
  327. "z": "27a36387.d08f7c",
  328. "name": "",
  329. "x": 930,
  330. "y": 1060,
  331. "wires": [
  332. [
  333. "22b2b366.d4ca5c"
  334. ]
  335. ]
  336. },
  337. {
  338. "id": "4fcbf9b0.9fc458",
  339. "type": "subflow:194463a7.c501ac",
  340. "z": "27a36387.d08f7c",
  341. "name": "",
  342. "x": 710,
  343. "y": 1020,
  344. "wires": [
  345. [
  346. "25dd1c10.12a8e4"
  347. ]
  348. ]
  349. },
  350. {
  351. "id": "afcc1cae.4ca9e",
  352. "type": "server-events",
  353. "z": "27a36387.d08f7c",
  354. "name": "incoming data",
  355. "server": "aac717d.c0c40e8",
  356. "x": 90,
  357. "y": 560,
  358. "wires": [
  359. [
  360. "7160f9d7.feaa08",
  361. "ebb909f8.d606f8",
  362. "79606a20.4bc754"
  363. ]
  364. ]
  365. },
  366. {
  367. "id": "ebb909f8.d606f8",
  368. "type": "switch",
  369. "z": "27a36387.d08f7c",
  370. "name": "is telegram callback",
  371. "property": "payload.event_type",
  372. "propertyType": "msg",
  373. "rules": [
  374. {
  375. "t": "eq",
  376. "v": "telegram_callback",
  377. "vt": "str"
  378. }
  379. ],
  380. "checkall": "true",
  381. "outputs": 1,
  382. "x": 310,
  383. "y": 560,
  384. "wires": [
  385. [
  386. "7576db61.019664",
  387. "97051056.51fa3"
  388. ]
  389. ]
  390. },
  391. {
  392. "id": "7576db61.019664",
  393. "type": "switch",
  394. "z": "27a36387.d08f7c",
  395. "name": "/still_alive",
  396. "property": "payload.event.data",
  397. "propertyType": "msg",
  398. "rules": [
  399. {
  400. "t": "eq",
  401. "v": "/still_alive",
  402. "vt": "str"
  403. }
  404. ],
  405. "checkall": "true",
  406. "outputs": 1,
  407. "x": 520,
  408. "y": 560,
  409. "wires": [
  410. [
  411. "ac88f05d.dd03a",
  412. "a1037051.1dbc"
  413. ]
  414. ]
  415. },
  416. {
  417. "id": "ac88f05d.dd03a",
  418. "type": "function",
  419. "z": "27a36387.d08f7c",
  420. "name": "set callback answer",
  421. "func": "var p = msg.payload;\nreturn {\n payload: {\n data: {\n callback_query_id: p.event.id,\n message: 'Glückwunsch, du Überlebenskünstler!'\n }\n }\n}",
  422. "outputs": 1,
  423. "noerr": 0,
  424. "x": 790,
  425. "y": 540,
  426. "wires": [
  427. [
  428. "37d77a7d.6302d6"
  429. ]
  430. ]
  431. },
  432. {
  433. "id": "a1037051.1dbc",
  434. "type": "function",
  435. "z": "27a36387.d08f7c",
  436. "name": "set edit message",
  437. "func": "var p = msg.payload;\nreturn {\n payload: {\n data: {\n message_id: p.event.message.message_id,\n chat_id: p.event.message.chat.id,\n message: 'Der CO₂-Wert ist über 2000ppm. Es gibt aber mindestens einen Überlebenden.'\n }\n }\n}",
  438. "outputs": 1,
  439. "noerr": 0,
  440. "x": 790,
  441. "y": 580,
  442. "wires": [
  443. [
  444. "c4cf1cde.3858d"
  445. ]
  446. ]
  447. },
  448. {
  449. "id": "c4cf1cde.3858d",
  450. "type": "api-call-service",
  451. "z": "27a36387.d08f7c",
  452. "name": "edit message",
  453. "server": "aac717d.c0c40e8",
  454. "service_domain": "telegram_bot",
  455. "service": "edit_message",
  456. "data": "{}",
  457. "x": 1000,
  458. "y": 580,
  459. "wires": [
  460. []
  461. ]
  462. },
  463. {
  464. "id": "37d77a7d.6302d6",
  465. "type": "api-call-service",
  466. "z": "27a36387.d08f7c",
  467. "name": "send callback answer",
  468. "server": "aac717d.c0c40e8",
  469. "service_domain": "telegram_bot",
  470. "service": "answer_callback_query",
  471. "data": "{}",
  472. "x": 1020,
  473. "y": 540,
  474. "wires": [
  475. []
  476. ]
  477. },
  478. {
  479. "id": "aac717d.c0c40e8",
  480. "type": "server",
  481. "z": "",
  482. "name": "Home Assistant"
  483. }
  484. ]
Add Comment
Please, Sign In to add comment