Last active
May 27, 2021 07:37
-
-
Save ReDetection/884e1616f1bad706470f2b2c646bb293 to your computer and use it in GitHub Desktop.
Exported Node-Red flow for automatic light control. Install following plugins into Node-Red: node-red-contrib-home-assistant-websocket, node-red-contrib-frp, node-red-contrib-time-range-switch. See https://vas3k.club/post/3516/ for a nice explanation (In Russian)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "da5a0b28.008b", | |
"type": "subflow", | |
"name": "Room light v3 supported command?", | |
"info": "", | |
"category": "", | |
"in": [ | |
{ | |
"x": 73.33333015441895, | |
"y": 210.00000190734863, | |
"wires": [ | |
{ | |
"id": "d78fcda6.6a5b3" | |
} | |
] | |
} | |
], | |
"out": [ | |
{ | |
"x": 484, | |
"y": 107, | |
"wires": [ | |
{ | |
"id": "d78fcda6.6a5b3", | |
"port": 0 | |
} | |
] | |
}, | |
{ | |
"x": 476, | |
"y": 157.99999237060547, | |
"wires": [ | |
{ | |
"id": "d78fcda6.6a5b3", | |
"port": 1 | |
} | |
] | |
}, | |
{ | |
"x": 466, | |
"y": 215.99999237060547, | |
"wires": [ | |
{ | |
"id": "d78fcda6.6a5b3", | |
"port": 2 | |
} | |
] | |
}, | |
{ | |
"x": 603.777795791626, | |
"y": 235.44447231292725, | |
"wires": [ | |
{ | |
"id": "3790313d.c38b4e", | |
"port": 0 | |
} | |
] | |
}, | |
{ | |
"x": 595.5555629730225, | |
"y": 312.22218132019043, | |
"wires": [ | |
{ | |
"id": "3790313d.c38b4e", | |
"port": 1 | |
} | |
] | |
} | |
], | |
"env": [] | |
}, | |
{ | |
"id": "d78fcda6.6a5b3", | |
"type": "switch", | |
"z": "da5a0b28.008b", | |
"name": "", | |
"property": "payload", | |
"propertyType": "msg", | |
"rules": [ | |
{ | |
"t": "regex", | |
"v": ".*_double", | |
"vt": "str", | |
"case": false | |
}, | |
{ | |
"t": "eq", | |
"v": "both", | |
"vt": "str" | |
}, | |
{ | |
"t": "eq", | |
"v": "both_long", | |
"vt": "str" | |
}, | |
{ | |
"t": "else" | |
} | |
], | |
"checkall": "false", | |
"repair": false, | |
"outputs": 4, | |
"x": 214.44443893432617, | |
"y": 211.11110877990723, | |
"wires": [ | |
[], | |
[], | |
[], | |
[ | |
"3790313d.c38b4e" | |
] | |
] | |
}, | |
{ | |
"id": "3790313d.c38b4e", | |
"type": "function", | |
"z": "da5a0b28.008b", | |
"name": "supported scene?", | |
"func": "switch(msg.payload) {\n\tcase 'left_long': \n\tcase 'right_long': \n\tcase 'left': \n\tcase 'right': \n return [msg, null];\n\tdefault: \n\t\treturn [null, msg];\n}", | |
"outputs": 2, | |
"noerr": 0, | |
"x": 425.18516540527344, | |
"y": 269.6296215057373, | |
"wires": [ | |
[], | |
[] | |
] | |
}, | |
{ | |
"id": "e94199b3.c9ff4", | |
"type": "subflow", | |
"name": "combine with previous", | |
"info": "", | |
"category": "", | |
"in": [ | |
{ | |
"x": 210, | |
"y": 216.99999237060547, | |
"wires": [ | |
{ | |
"id": "d556880c.9e7fb8" | |
} | |
] | |
} | |
], | |
"out": [ | |
{ | |
"x": 960.9999694824219, | |
"y": 168.99999237060547, | |
"wires": [ | |
{ | |
"id": "d556880c.9e7fb8", | |
"port": 0 | |
} | |
] | |
} | |
], | |
"env": [] | |
}, | |
{ | |
"id": "d556880c.9e7fb8", | |
"type": "frp-scan", | |
"z": "e94199b3.c9ff4", | |
"name": "combine with previous", | |
"topic": "", | |
"seed": "{}", | |
"func": "\nfunction (accumulatedValue, payload) {\n\tlet safeAcc = Object.assign({\"current\": null}, accumulatedValue ? accumulatedValue : {});\n\tif (JSON.stringify(safeAcc.current) === JSON.stringify(payload)) {\n\t safeAcc.repeat_number = safeAcc.repeat_number ? safeAcc.repeat_number + 1 : 1;\n\t} else {\n\t\tsafeAcc.repeat_number = 0;\n\t}\n\treturn Object.assign({}, {\"previous\": safeAcc.current, \"repeat_number\": safeAcc.repeat_number}, {\"current\": payload});\n}\n", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 410.6666564941406, | |
"y": 216.6666488647461, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "59ddd4fd.6d5f1c", | |
"type": "subflow", | |
"name": "count repeats", | |
"info": "", | |
"category": "", | |
"in": [ | |
{ | |
"x": 82, | |
"y": 290.99999237060547, | |
"wires": [ | |
{ | |
"id": "76f1506d.474f18" | |
} | |
] | |
} | |
], | |
"out": [ | |
{ | |
"x": 895.9999694824219, | |
"y": 256.99999237060547, | |
"wires": [ | |
{ | |
"id": "96d899d4.0ad4f", | |
"port": 0 | |
} | |
] | |
} | |
], | |
"env": [], | |
"status": { | |
"x": 897.9999694824219, | |
"y": 347.99999237060547, | |
"wires": [ | |
{ | |
"id": "e5abace9.92ba", | |
"port": 0 | |
} | |
] | |
} | |
}, | |
{ | |
"id": "76f1506d.474f18", | |
"type": "subflow:e94199b3.c9ff4", | |
"z": "59ddd4fd.6d5f1c", | |
"name": "", | |
"env": [], | |
"x": 312.3333435058594, | |
"y": 302.33333587646484, | |
"wires": [ | |
[ | |
"96d899d4.0ad4f", | |
"e5abace9.92ba" | |
] | |
] | |
}, | |
{ | |
"id": "e5abace9.92ba", | |
"type": "frp-map", | |
"z": "59ddd4fd.6d5f1c", | |
"name": "map repeat number", | |
"topic": "", | |
"func": "function (payload) {\n\treturn payload.repeat_number;\n}", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 691.6666259765625, | |
"y": 345.6666564941406, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "96d899d4.0ad4f", | |
"type": "function", | |
"z": "59ddd4fd.6d5f1c", | |
"name": "hide in msg, recover payload", | |
"func": "msg.repeat_number = msg.payload.repeat_number;\nmsg.payload = msg.payload.current;\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 716.6666259765625, | |
"y": 255, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "541338cb.3cf27", | |
"type": "subflow", | |
"name": "Lights v4", | |
"info": "", | |
"category": "", | |
"in": [ | |
{ | |
"x": 362, | |
"y": 732.0000305175781, | |
"wires": [ | |
{ | |
"id": "20143259.70f266" | |
} | |
] | |
} | |
], | |
"out": [ | |
{ | |
"x": 2585.9999084472656, | |
"y": 633.9999847412109, | |
"wires": [ | |
{ | |
"id": "2b4efcde.3c9bd4", | |
"port": 0 | |
} | |
] | |
}, | |
{ | |
"x": 2588.999969482422, | |
"y": 809.9999847412109, | |
"wires": [ | |
{ | |
"id": "4e8f7cfd.5edf5c", | |
"port": 0 | |
} | |
] | |
}, | |
{ | |
"x": 2595.999969482422, | |
"y": 867.9999847412109, | |
"wires": [ | |
{ | |
"id": "ea6c9fb3.c183f", | |
"port": 0 | |
} | |
] | |
} | |
], | |
"env": [ | |
{ | |
"name": "entities", | |
"type": "str", | |
"value": "" | |
} | |
], | |
"status": { | |
"x": 2596, | |
"y": 741.9999847412109, | |
"wires": [ | |
{ | |
"id": "4e8f7cfd.5edf5c", | |
"port": 0 | |
}, | |
{ | |
"id": "ea6c9fb3.c183f", | |
"port": 0 | |
}, | |
{ | |
"id": "2b4efcde.3c9bd4", | |
"port": 0 | |
} | |
] | |
} | |
}, | |
{ | |
"id": "8ac13e2a.a85858", | |
"type": "function", | |
"z": "541338cb.3cf27", | |
"name": "temperature select", | |
"func": "switch(msg.payload) {\n\tcase 'left_double': \n\t\tmsg.payload = {\"color_temp\": 400};\n\t\tbreak;\n\tcase 'both_double': \n\t\tmsg.payload = {\"color_temp\": 200};\n\t\tbreak;\n\tcase 'right_double': \n\t\tmsg.payload = {\"color_temp\": 50};\n\t\tbreak;\n\tdefault: \n\t\treturn;\n}\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1785.333251953125, | |
"y": 649.3333129882812, | |
"wires": [ | |
[ | |
"2b4efcde.3c9bd4" | |
] | |
] | |
}, | |
{ | |
"id": "2b4efcde.3c9bd4", | |
"type": "frp-scan", | |
"z": "541338cb.3cf27", | |
"name": "accumulate", | |
"topic": "", | |
"seed": "{}", | |
"func": "function (accumulatedValue, payload) {\n\treturn Object.assign({ \"transition\": 0.3}, accumulatedValue, payload);\n}", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 2417.3331604003906, | |
"y": 649.9999542236328, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "86ba244a.b4a67", | |
"type": "function", | |
"z": "541338cb.3cf27", | |
"name": "scene select", | |
"func": "switch(msg.payload) {\n\tcase 'left_long': \n\t\tmsg.payload = {\"brightness\": 20, \"color_temp\": 450};\n\t\tbreak;\n\tcase 'right_long': \n\t\tmsg.payload = {\"brightness\": 100, \"color_temp\": 350};\n\t\tbreak;\n\tcase 'left': \n\t\tmsg.payload = {\"brightness\": 180, \"color_temp\": 200};\n\t\tbreak;\n\tcase 'right': \n\t\tmsg.payload = {\"brightness\": 255, \"color_temp\": 50};\n\t\tbreak;\n\tdefault: \n\t\treturn;\n}\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1710.9998779296875, | |
"y": 814.9999542236328, | |
"wires": [ | |
[ | |
"b2cb0bcd.d7fce" | |
] | |
] | |
}, | |
{ | |
"id": "4e8f7cfd.5edf5c", | |
"type": "template", | |
"z": "541338cb.3cf27", | |
"name": "{0}", | |
"field": "payload", | |
"fieldType": "msg", | |
"format": "handlebars", | |
"syntax": "mustache", | |
"template": "{\"brightness\":0}", | |
"output": "json", | |
"x": 2409.999755859375, | |
"y": 754.3333129882812, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "ea6c9fb3.c183f", | |
"type": "template", | |
"z": "541338cb.3cf27", | |
"name": "{0}", | |
"field": "payload", | |
"fieldType": "msg", | |
"format": "handlebars", | |
"syntax": "mustache", | |
"template": "{\"brightness\":0}", | |
"output": "json", | |
"x": 2411.333251953125, | |
"y": 808, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "5405792c.22e8e8", | |
"type": "subflow:59ddd4fd.6d5f1c", | |
"z": "541338cb.3cf27", | |
"name": "", | |
"env": [], | |
"x": 1139.6666107177734, | |
"y": 724.9999876022339, | |
"wires": [ | |
[ | |
"cce9046b.f5fa5" | |
] | |
] | |
}, | |
{ | |
"id": "cce9046b.f5fa5", | |
"type": "subflow:da5a0b28.008b", | |
"z": "541338cb.3cf27", | |
"name": "", | |
"env": [], | |
"x": 1423.7776794433594, | |
"y": 728.3332567214966, | |
"wires": [ | |
[ | |
"8ac13e2a.a85858" | |
], | |
[ | |
"4e8f7cfd.5edf5c" | |
], | |
[ | |
"ea6c9fb3.c183f" | |
], | |
[ | |
"86ba244a.b4a67" | |
], | |
[] | |
] | |
}, | |
{ | |
"id": "20143259.70f266", | |
"type": "subflow:da5a0b28.008b", | |
"z": "541338cb.3cf27", | |
"name": "", | |
"env": [], | |
"x": 790.7777557373047, | |
"y": 727.4443597793579, | |
"wires": [ | |
[ | |
"5405792c.22e8e8" | |
], | |
[ | |
"5405792c.22e8e8" | |
], | |
[ | |
"5405792c.22e8e8" | |
], | |
[ | |
"5405792c.22e8e8" | |
], | |
[] | |
] | |
}, | |
{ | |
"id": "f4b1e925.5afca", | |
"type": "api-current-state", | |
"z": "541338cb.3cf27", | |
"name": "", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"outputs": 1, | |
"halt_if": "", | |
"halt_if_type": "str", | |
"halt_if_compare": "is", | |
"override_topic": false, | |
"entity_id": "{{{entity_query}}}", | |
"state_type": "str", | |
"state_location": "payload-loaded", | |
"override_payload": "msg", | |
"entity_location": "data", | |
"override_data": "msg", | |
"blockInputOverrides": false, | |
"x": 1854.4195251464844, | |
"y": 887.216703414917, | |
"wires": [ | |
[ | |
"187011bc.6e12ee" | |
] | |
] | |
}, | |
{ | |
"id": "df18a4f6.1a7328", | |
"type": "function", | |
"z": "541338cb.3cf27", | |
"name": "compare", | |
"func": "var tolerance = function(a, b){\n return a > b ? a - b : b - a;\n}\n\nif (tolerance(msg.data.attributes.brightness, msg.payload.brightness) < 2 && \n tolerance(msg.data.attributes.color_temp, msg.payload.color_temp) < 2) {\n return [null, msg];\n} else {\n return [msg, null];\n}\n", | |
"outputs": 2, | |
"noerr": 0, | |
"x": 2243, | |
"y": 702.3333892822266, | |
"wires": [ | |
[ | |
"2b4efcde.3c9bd4" | |
], | |
[ | |
"4e8f7cfd.5edf5c" | |
] | |
], | |
"outputLabels": [ | |
"different", | |
"matching" | |
], | |
"icon": "font-awesome/fa-balance-scale" | |
}, | |
{ | |
"id": "b2cb0bcd.d7fce", | |
"type": "change", | |
"z": "541338cb.3cf27", | |
"name": "", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "entity_query", | |
"pt": "msg", | |
"to": "entities", | |
"tot": "env" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 1907.3333740234375, | |
"y": 816.0000152587891, | |
"wires": [ | |
[ | |
"f4b1e925.5afca" | |
] | |
] | |
}, | |
{ | |
"id": "187011bc.6e12ee", | |
"type": "function", | |
"z": "541338cb.3cf27", | |
"name": "map off state to 0 brightness", | |
"func": "if (msg.data.attributes.state == \"OFF\") {\n msg.data.attributes.brightness = 0;\n}\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 2139.333251953125, | |
"y": 887.3333892822266, | |
"wires": [ | |
[ | |
"df18a4f6.1a7328" | |
] | |
] | |
}, | |
{ | |
"id": "3108ee7a.1dddd2", | |
"type": "subflow", | |
"name": "Turn off bedroom", | |
"info": "", | |
"category": "", | |
"in": [ | |
{ | |
"x": 298, | |
"y": 335.99999237060547, | |
"wires": [ | |
{ | |
"id": "eb8705be.bea22" | |
}, | |
{ | |
"id": "b2ca689c.409e78" | |
} | |
] | |
} | |
], | |
"out": [], | |
"env": [], | |
"icon": "node-red/alert.png" | |
}, | |
{ | |
"id": "eb8705be.bea22", | |
"type": "api-call-service", | |
"z": "3108ee7a.1dddd2", | |
"name": "bedroom ceiling light", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"debugenabled": false, | |
"service_domain": "light", | |
"service": "turn_on", | |
"entityId": "light.0x000b3cfffef56106_light, light.bedroom_white_l, light.bedroom_write_r_light", | |
"data": "msg.payload", | |
"dataType": "jsonata", | |
"mergecontext": "", | |
"output_location": "", | |
"output_location_type": "none", | |
"mustacheAltTags": false, | |
"x": 540.6666259765625, | |
"y": 291.6666564941406, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "b2ca689c.409e78", | |
"type": "api-call-service", | |
"z": "3108ee7a.1dddd2", | |
"name": "ikea halvstop lamp", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"debugenabled": false, | |
"service_domain": "switch", | |
"service": "turn_off", | |
"entityId": "switch.halvstop_l2", | |
"data": "", | |
"dataType": "json", | |
"mergecontext": "", | |
"output_location": "", | |
"output_location_type": "none", | |
"mustacheAltTags": false, | |
"x": 531.6666259765625, | |
"y": 367.6666564941406, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "57f34b0e.b4ce2c", | |
"type": "subflow", | |
"name": "Turn off all lights", | |
"info": "", | |
"category": "", | |
"in": [ | |
{ | |
"x": 298, | |
"y": 374.99999237060547, | |
"wires": [ | |
{ | |
"id": "693565df.bbcbac" | |
}, | |
{ | |
"id": "9a4fa9fe.b5414" | |
}, | |
{ | |
"id": "37050c83.0c5364" | |
}, | |
{ | |
"id": "9297ae12.c583d8" | |
} | |
] | |
} | |
], | |
"out": [], | |
"env": [], | |
"icon": "node-red/alert.png" | |
}, | |
{ | |
"id": "693565df.bbcbac", | |
"type": "api-call-service", | |
"z": "57f34b0e.b4ce2c", | |
"name": "kitchen ceiling light", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"debugenabled": false, | |
"service_domain": "light", | |
"service": "turn_on", | |
"entityId": "light.kitchen_aqara_2, light.kitchen_white_light", | |
"data": "msg.payload", | |
"dataType": "jsonata", | |
"mergecontext": "", | |
"output_location": "", | |
"output_location_type": "none", | |
"mustacheAltTags": false, | |
"x": 596.6666259765625, | |
"y": 313.6666564941406, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "9a4fa9fe.b5414", | |
"type": "subflow:3108ee7a.1dddd2", | |
"z": "57f34b0e.b4ce2c", | |
"name": "", | |
"env": [], | |
"x": 565.3333435058594, | |
"y": 412.3333511352539, | |
"wires": [] | |
}, | |
{ | |
"id": "37050c83.0c5364", | |
"type": "api-call-service", | |
"z": "57f34b0e.b4ce2c", | |
"name": "hall lights off", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"debugenabled": false, | |
"service_domain": "light", | |
"service": "turn_off", | |
"entityId": "light.0x00158d00045dc184_light, light.hall2", | |
"data": "{}", | |
"dataType": "json", | |
"mergecontext": "", | |
"output_location": "", | |
"output_location_type": "none", | |
"mustacheAltTags": false, | |
"x": 539.6666259765625, | |
"y": 480.6666564941406, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "89ef81e1.317048", | |
"type": "api-call-service", | |
"z": "57f34b0e.b4ce2c", | |
"name": "turn off white plug", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"debugenabled": false, | |
"service_domain": "switch", | |
"service": "turn_off", | |
"entityId": "switch.0x00124b0009fe312b_switch", | |
"data": "", | |
"dataType": "json", | |
"mergecontext": "", | |
"output_location": "", | |
"output_location_type": "none", | |
"mustacheAltTags": false, | |
"x": 579, | |
"y": 544.5, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "9297ae12.c583d8", | |
"type": "api-call-service", | |
"z": "57f34b0e.b4ce2c", | |
"name": "turn off bathroom", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"debugenabled": false, | |
"service_domain": "light", | |
"service": "turn_off", | |
"entityId": "light.0x00158d00054e6b80", | |
"data": "{}", | |
"dataType": "json", | |
"mergecontext": "", | |
"output_location": "", | |
"output_location_type": "none", | |
"mustacheAltTags": false, | |
"x": 584.8345947265625, | |
"y": 629.941162109375, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "923c3b.0135b3c8", | |
"type": "api-call-service", | |
"z": "6839ad73.664374", | |
"name": "Toggle hall lights", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"debugenabled": false, | |
"service_domain": "light", | |
"service": "turn_on", | |
"entityId": "light.0x00158d00045dc184_light, light.hall2", | |
"data": "msg.payload", | |
"dataType": "jsonata", | |
"mergecontext": "", | |
"output_location": "", | |
"output_location_type": "none", | |
"mustacheAltTags": false, | |
"x": 786.6666259765625, | |
"y": 319.6666564941406, | |
"wires": [ | |
[ | |
"3ffd6bc6.80eff4", | |
"ef535868.6e0cc" | |
] | |
] | |
}, | |
{ | |
"id": "3ffd6bc6.80eff4", | |
"type": "trigger", | |
"z": "6839ad73.664374", | |
"op1": "1", | |
"op2": "0", | |
"op1type": "str", | |
"op2type": "str", | |
"duration": "10", | |
"extend": false, | |
"units": "s", | |
"reset": "reset", | |
"bytopic": "all", | |
"name": "", | |
"x": 1158.2231140136719, | |
"y": 399.09191131591797, | |
"wires": [ | |
[ | |
"8cceb2e.402b0d" | |
] | |
] | |
}, | |
{ | |
"id": "2d438147.24b3f6", | |
"type": "api-call-service", | |
"z": "6839ad73.664374", | |
"name": "hall lights off", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"debugenabled": false, | |
"service_domain": "light", | |
"service": "turn_off", | |
"entityId": "light.0x00158d00045dc184_light, light.hall2", | |
"data": "{}", | |
"dataType": "json", | |
"mergecontext": "", | |
"output_location": "", | |
"output_location_type": "none", | |
"mustacheAltTags": false, | |
"x": 782.8727264404297, | |
"y": 391.3225402832031, | |
"wires": [ | |
[ | |
"3ffd6bc6.80eff4" | |
] | |
] | |
}, | |
{ | |
"id": "6d521f46.b93008", | |
"type": "server-state-changed", | |
"z": "6839ad73.664374", | |
"name": "hall buttons", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"entityidfilter": "sensor.0x00158d000128f1dd_click", | |
"entityidfiltertype": "exact", | |
"outputinitially": false, | |
"state_type": "str", | |
"haltifstate": "", | |
"halt_if_type": "str", | |
"halt_if_compare": "is", | |
"outputs": 1, | |
"output_only_on_state_change": true, | |
"x": 278.29058837890625, | |
"y": 325.9349365234375, | |
"wires": [ | |
[ | |
"a2ff02ff.932458", | |
"c12a422f.3d681" | |
] | |
] | |
}, | |
{ | |
"id": "ffee5ca3.3954b", | |
"type": "server-state-changed", | |
"z": "6839ad73.664374", | |
"name": "entrance buttons", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"entityidfilter": "sensor.0x00158d000183f4a4_click", | |
"entityidfiltertype": "exact", | |
"outputinitially": false, | |
"state_type": "str", | |
"haltifstate": "", | |
"halt_if_type": "str", | |
"halt_if_compare": "is", | |
"outputs": 1, | |
"output_only_on_state_change": true, | |
"x": 288.29058837890625, | |
"y": 406.93495178222656, | |
"wires": [ | |
[ | |
"c12a422f.3d681" | |
] | |
] | |
}, | |
{ | |
"id": "ebc63a54.e3ea78", | |
"type": "server-state-changed", | |
"z": "6839ad73.664374", | |
"name": "Door opens or closes?", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"exposeToHomeAssistant": false, | |
"haConfig": [ | |
{ | |
"property": "name", | |
"value": "" | |
}, | |
{ | |
"property": "icon", | |
"value": "" | |
} | |
], | |
"entityidfilter": "binary_sensor.0x00158d00027b4d21_contact", | |
"entityidfiltertype": "exact", | |
"outputinitially": false, | |
"state_type": "habool", | |
"haltifstate": "true", | |
"halt_if_type": "bool", | |
"halt_if_compare": "is", | |
"outputs": 2, | |
"output_only_on_state_change": true, | |
"for": "", | |
"forType": "num", | |
"forUnits": "minutes", | |
"ignorePrevStateNull": false, | |
"ignorePrevStateUnknown": false, | |
"ignorePrevStateUnavailable": false, | |
"ignoreCurrentStateUnknown": false, | |
"ignoreCurrentStateUnavailable": false, | |
"x": 105, | |
"y": 710.0000915527344, | |
"wires": [ | |
[ | |
"3aaa6f4b.1ea5a" | |
], | |
[ | |
"3aaa6f4b.1ea5a" | |
] | |
] | |
}, | |
{ | |
"id": "ce5f19c6.2f90b", | |
"type": "time-range-switch", | |
"z": "6839ad73.664374", | |
"name": "If evening", | |
"lat": "55.018803", | |
"lon": "82.933952", | |
"startTime": "sunsetStart", | |
"endTime": "23:00", | |
"startOffset": 0, | |
"endOffset": 0, | |
"x": 1261.3451538085938, | |
"y": 777.0413208007812, | |
"wires": [ | |
[ | |
"cdad4b2f.cb4a18" | |
], | |
[] | |
] | |
}, | |
{ | |
"id": "cdad4b2f.cb4a18", | |
"type": "api-call-service", | |
"z": "6839ad73.664374", | |
"name": "", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"debugenabled": false, | |
"service_domain": "light", | |
"service": "turn_on", | |
"entityId": "light.0x00158d00045dc184_light, light.hall2", | |
"data": "{\"brightness\": 255, \"transition\": 0.3}", | |
"dataType": "json", | |
"mergecontext": "", | |
"output_location": "", | |
"output_location_type": "none", | |
"mustacheAltTags": false, | |
"x": 1475.2276000976562, | |
"y": 762.4539794921875, | |
"wires": [ | |
[ | |
"25c94ed7.0fba92" | |
] | |
] | |
}, | |
{ | |
"id": "96cad858.0e586", | |
"type": "time-range-switch", | |
"z": "6839ad73.664374", | |
"name": "If night", | |
"lat": "55.018803", | |
"lon": "82.933952", | |
"startTime": "23:00", | |
"endTime": "04:00", | |
"startOffset": 0, | |
"endOffset": 0, | |
"x": 1264.5125122070312, | |
"y": 868.0987548828125, | |
"wires": [ | |
[ | |
"80279482.01814" | |
], | |
[] | |
] | |
}, | |
{ | |
"id": "80279482.01814", | |
"type": "api-call-service", | |
"z": "6839ad73.664374", | |
"name": "turn on dim", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"debugenabled": false, | |
"service_domain": "light", | |
"service": "turn_on", | |
"entityId": "light.0x00158d00045dc184_light, light.hall2", | |
"data": "{\"brightness\": 30, \"transition\": 0.3}", | |
"dataType": "json", | |
"mergecontext": "", | |
"output_location": "", | |
"output_location_type": "none", | |
"mustacheAltTags": false, | |
"x": 1503.3948364257812, | |
"y": 844.5114135742188, | |
"wires": [ | |
[ | |
"25c94ed7.0fba92" | |
] | |
] | |
}, | |
{ | |
"id": "ef65f8b5.5df82", | |
"type": "time-range-switch", | |
"z": "6839ad73.664374", | |
"name": "If morning", | |
"lat": "55.018803", | |
"lon": "82.933952", | |
"startTime": "06:00", | |
"endTime": "10:00", | |
"startOffset": 0, | |
"endOffset": 0, | |
"x": 1262.8346557617188, | |
"y": 642.0574645996094, | |
"wires": [ | |
[ | |
"9f9ed4a9.f6316" | |
], | |
[] | |
] | |
}, | |
{ | |
"id": "9f9ed4a9.f6316", | |
"type": "api-call-service", | |
"z": "6839ad73.664374", | |
"name": "", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"debugenabled": false, | |
"service_domain": "light", | |
"service": "turn_off", | |
"entityId": "light.0x00158d00045dc184_light, light.hall2", | |
"data": "", | |
"dataType": "json", | |
"mergecontext": "", | |
"output_location": "", | |
"output_location_type": "none", | |
"mustacheAltTags": false, | |
"x": 1466.7170753479004, | |
"y": 642.4701042175293, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "36c87420.4a1d94", | |
"type": "inject", | |
"z": "6839ad73.664374", | |
"name": "", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 1264.8346557617188, | |
"y": 680.0574798583984, | |
"wires": [ | |
[ | |
"9f9ed4a9.f6316" | |
] | |
] | |
}, | |
{ | |
"id": "25c94ed7.0fba92", | |
"type": "trigger", | |
"z": "6839ad73.664374", | |
"op1": "", | |
"op2": "0", | |
"op1type": "nul", | |
"op2type": "str", | |
"duration": "7", | |
"extend": true, | |
"units": "min", | |
"reset": "reset", | |
"bytopic": "all", | |
"name": "", | |
"x": 1727.0699615478516, | |
"y": 777.0575256347656, | |
"wires": [ | |
[ | |
"6ff47344.d1a834" | |
] | |
] | |
}, | |
{ | |
"id": "a77ca709.841b6", | |
"type": "api-call-service", | |
"z": "6839ad73.664374", | |
"name": "", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"debugenabled": false, | |
"service_domain": "light", | |
"service": "turn_off", | |
"entityId": "light.0x00158d00045dc184_light, light.hall2", | |
"data": "{\"transition\": 0.3}", | |
"dataType": "json", | |
"mergecontext": "", | |
"output_location": "", | |
"output_location_type": "none", | |
"mustacheAltTags": false, | |
"x": 2198.0699462890625, | |
"y": 701.0574951171875, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "8c106e46.a19a5", | |
"type": "inject", | |
"z": "6839ad73.664374", | |
"name": "", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 1264.0699462890625, | |
"y": 743.0574798583984, | |
"wires": [ | |
[ | |
"cdad4b2f.cb4a18" | |
] | |
] | |
}, | |
{ | |
"id": "b51b095.d42c578", | |
"type": "frp-filter", | |
"z": "6839ad73.664374", | |
"name": "if not filtered", | |
"topic": "", | |
"func": "function (payload) {\n\treturn payload.filter_door_events === \"0\";\n}", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 783.6546249389648, | |
"y": 708.4140319824219, | |
"wires": [ | |
[ | |
"dfd1e687.090c98", | |
"ef65f8b5.5df82", | |
"517b08eb.938ab8" | |
] | |
] | |
}, | |
{ | |
"id": "8cceb2e.402b0d", | |
"type": "change", | |
"z": "6839ad73.664374", | |
"name": "", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "filter_door_events", | |
"pt": "flow", | |
"to": "payload", | |
"tot": "msg" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 701.6507797241211, | |
"y": 672.3845825195312, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "3f0bc519.523c32", | |
"type": "change", | |
"z": "6839ad73.664374", | |
"name": "mix filter state", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload.filter_door_events", | |
"pt": "msg", | |
"to": "filter_door_events", | |
"tot": "flow" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 615.4229354858398, | |
"y": 709.4103698730469, | |
"wires": [ | |
[ | |
"b51b095.d42c578" | |
] | |
] | |
}, | |
{ | |
"id": "3aaa6f4b.1ea5a", | |
"type": "template", | |
"z": "6839ad73.664374", | |
"name": "", | |
"field": "payload", | |
"fieldType": "msg", | |
"format": "handlebars", | |
"syntax": "mustache", | |
"template": "{ \"state\": \"{{payload}}\" }", | |
"output": "json", | |
"x": 374.64337158203125, | |
"y": 708.8515319824219, | |
"wires": [ | |
[ | |
"3f0bc519.523c32" | |
] | |
] | |
}, | |
{ | |
"id": "374a594c.1ce8c6", | |
"type": "subflow:57f34b0e.b4ce2c", | |
"z": "6839ad73.664374", | |
"name": "", | |
"env": [], | |
"x": 798.6667098999023, | |
"y": 460.6666488647461, | |
"wires": [] | |
}, | |
{ | |
"id": "e93421b8.0911f", | |
"type": "frp-filter", | |
"z": "6839ad73.664374", | |
"name": "if not filtered", | |
"topic": "", | |
"func": "function (payload) {\n\treturn payload.filter_door_events === \"0\";\n}", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 784.4641952514648, | |
"y": 780.6521606445312, | |
"wires": [ | |
[ | |
"70470a.9698a8f8" | |
] | |
] | |
}, | |
{ | |
"id": "bc5befa8.6a2d28", | |
"type": "change", | |
"z": "6839ad73.664374", | |
"name": "mix filter state", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload.filter_door_events", | |
"pt": "msg", | |
"to": "filter_door_events", | |
"tot": "flow" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 616.2325057983398, | |
"y": 781.6484985351562, | |
"wires": [ | |
[ | |
"e93421b8.0911f" | |
] | |
] | |
}, | |
{ | |
"id": "ba35baad.9a07f8", | |
"type": "template", | |
"z": "6839ad73.664374", | |
"name": "", | |
"field": "payload", | |
"fieldType": "msg", | |
"format": "handlebars", | |
"syntax": "mustache", | |
"template": "{ \"state\": \"{{payload}}\" }", | |
"output": "json", | |
"x": 358.595703125, | |
"y": 886.089599609375, | |
"wires": [ | |
[ | |
"bc5befa8.6a2d28" | |
] | |
] | |
}, | |
{ | |
"id": "cdd33f87.d080b8", | |
"type": "server-state-changed", | |
"z": "6839ad73.664374", | |
"name": "Movement?", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"exposeToHomeAssistant": false, | |
"haConfig": [ | |
{ | |
"property": "name", | |
"value": "" | |
}, | |
{ | |
"property": "icon", | |
"value": "" | |
} | |
], | |
"entityidfilter": "binary_sensor.0x00158d00045fa060_occupancy", | |
"entityidfiltertype": "exact", | |
"outputinitially": false, | |
"state_type": "habool", | |
"haltifstate": "true", | |
"halt_if_type": "bool", | |
"halt_if_compare": "is", | |
"outputs": 2, | |
"output_only_on_state_change": true, | |
"for": "", | |
"forType": "num", | |
"forUnits": "minutes", | |
"ignorePrevStateNull": false, | |
"ignorePrevStateUnknown": false, | |
"ignorePrevStateUnavailable": false, | |
"ignoreCurrentStateUnknown": false, | |
"ignoreCurrentStateUnavailable": false, | |
"x": 117.22908020019531, | |
"y": 900.7006225585938, | |
"wires": [ | |
[ | |
"ba35baad.9a07f8" | |
], | |
[] | |
] | |
}, | |
{ | |
"id": "c12a422f.3d681", | |
"type": "subflow:541338cb.3cf27", | |
"z": "6839ad73.664374", | |
"name": "", | |
"env": [ | |
{ | |
"name": "entities", | |
"type": "str", | |
"value": "light.0x00158d00045dc184_light" | |
} | |
], | |
"x": 519.1060180664062, | |
"y": 375.6467604637146, | |
"wires": [ | |
[ | |
"923c3b.0135b3c8" | |
], | |
[ | |
"2d438147.24b3f6" | |
], | |
[ | |
"374a594c.1ce8c6" | |
] | |
] | |
}, | |
{ | |
"id": "6ff47344.d1a834", | |
"type": "api-current-state", | |
"z": "6839ad73.664374", | |
"name": "only when no movement", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"outputs": 2, | |
"halt_if": "off", | |
"halt_if_type": "str", | |
"halt_if_compare": "is", | |
"override_topic": false, | |
"entity_id": "binary_sensor.0x00158d00045fa060_occupancy", | |
"state_type": "str", | |
"state_location": "payload-loaded", | |
"override_payload": "msg", | |
"entity_location": "data", | |
"override_data": "msg", | |
"blockInputOverrides": false, | |
"x": 1946, | |
"y": 713, | |
"wires": [ | |
[ | |
"a77ca709.841b6" | |
], | |
[ | |
"25c94ed7.0fba92" | |
] | |
] | |
}, | |
{ | |
"id": "517b08eb.938ab8", | |
"type": "api-current-state", | |
"z": "6839ad73.664374", | |
"name": "only when lights off", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"outputs": 2, | |
"halt_if": "off", | |
"halt_if_type": "str", | |
"halt_if_compare": "is", | |
"override_topic": false, | |
"entity_id": "light.0x00158d00045dc184_light", | |
"state_type": "str", | |
"state_location": "payload-loaded", | |
"override_payload": "msg", | |
"entity_location": "data", | |
"override_data": "msg", | |
"blockInputOverrides": false, | |
"x": 1024.3335571289062, | |
"y": 737, | |
"wires": [ | |
[ | |
"ce5f19c6.2f90b", | |
"96cad858.0e586" | |
], | |
[] | |
] | |
}, | |
{ | |
"id": "70470a.9698a8f8", | |
"type": "api-current-state", | |
"z": "6839ad73.664374", | |
"name": "only when lights off", | |
"server": "8539c964.bbfa48", | |
"version": 1, | |
"outputs": 2, | |
"halt_if": "off", | |
"halt_if_type": "str", | |
"halt_if_compare": "is", | |
"override_topic": false, | |
"entity_id": "light.0x00158d00045dc184_light", | |
"state_type": "str", | |
"state_location": "payload-loaded", | |
"override_payload": "msg", | |
"entity_location": "data", | |
"override_data": "msg", | |
"blockInputOverrides": false, | |
"x": 1023.6669311523438, | |
"y": 823, | |
"wires": [ | |
[ | |
"7519559.325ecac" | |
], | |
[] | |
] | |
}, | |
{ | |
"id": "7519559.325ecac", | |
"type": "time-range-switch", | |
"z": "6839ad73.664374", | |
"name": "If night", | |
"lat": "55.018803", | |
"lon": "82.933952", | |
"startTime": "23:00", | |
"endTime": "04:00", | |
"startOffset": 0, | |
"endOffset": 0, | |
"x": 1262.666748046875, | |
"y": 821.0000305175781, | |
"wires": [ | |
[ | |
"80279482.01814" | |
], | |
[ | |
"cdad4b2f.cb4a18" | |
] | |
] | |
}, | |
{ | |
"id": "8539c964.bbfa48", | |
"type": "server", | |
"z": "", | |
"name": "Home Assistant", | |
"legacy": false, | |
"rejectUnauthorizedCerts": true, | |
"ha_boolean": "y|yes|true|on|home|open", | |
"connectionDelay": true | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment