Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [
- {
- "id": "194463a7.c501ac",
- "type": "subflow",
- "name": "Who is home?",
- "info": "",
- "in": [
- {
- "x": 60,
- "y": 60,
- "wires": [
- {
- "id": "c19c61b3.2a33f"
- }
- ]
- }
- ],
- "out": [
- {
- "x": 1120,
- "y": 60,
- "wires": [
- {
- "id": "8ee27d68.fe90b",
- "port": 0
- }
- ]
- }
- ]
- },
- {
- "id": "b4a281ad.7b804",
- "type": "join",
- "z": "194463a7.c501ac",
- "name": "",
- "mode": "custom",
- "build": "merged",
- "property": "payload",
- "propertyType": "msg",
- "key": "topic",
- "joiner": "\\n",
- "joinerType": "str",
- "accumulate": false,
- "timeout": "",
- "count": "2",
- "reduceRight": false,
- "reduceExp": "",
- "reduceInit": "",
- "reduceInitType": "",
- "reduceFixup": "",
- "x": 770,
- "y": 60,
- "wires": [
- [
- "8ee27d68.fe90b"
- ]
- ]
- },
- {
- "id": "8ee27d68.fe90b",
- "type": "function",
- "z": "194463a7.c501ac",
- "name": "set telegram service",
- "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}};",
- "outputs": 1,
- "noerr": 0,
- "x": 960,
- "y": 60,
- "wires": [
- []
- ]
- },
- {
- "id": "5d334d00.300524",
- "type": "api-get-history",
- "z": "194463a7.c501ac",
- "name": "get history user1",
- "server": "aac717d.c0c40e8",
- "startdate": "",
- "enddate": "",
- "entityid": "sensor.user1_status",
- "entityidtype": "includes",
- "x": 440,
- "y": 40,
- "wires": [
- [
- "66fd5763.b6e3b8"
- ]
- ]
- },
- {
- "id": "2572b25e.f3ef8e",
- "type": "api-get-history",
- "z": "194463a7.c501ac",
- "name": "get history user2",
- "server": "aac717d.c0c40e8",
- "startdate": "",
- "enddate": "",
- "entityid": "sensor.sebastian_status",
- "entityidtype": "includes",
- "x": 440,
- "y": 80,
- "wires": [
- [
- "c792d038.75f7b"
- ]
- ]
- },
- {
- "id": "c19c61b3.2a33f",
- "type": "moment",
- "z": "194463a7.c501ac",
- "name": "-15 min as startdate",
- "topic": "",
- "input": "",
- "inputType": "date",
- "inTz": "Etc/UTC",
- "adjAmount": "15",
- "adjType": "minutes",
- "adjDir": "subtract",
- "format": "",
- "locale": "POSIX",
- "output": "startdate",
- "outputType": "msg",
- "outTz": "Etc/UTC",
- "x": 220,
- "y": 60,
- "wires": [
- [
- "2572b25e.f3ef8e",
- "5d334d00.300524"
- ]
- ]
- },
- {
- "id": "66fd5763.b6e3b8",
- "type": "function",
- "z": "194463a7.c501ac",
- "name": "set user1",
- "func": "var home = msg.payload[0].some(function(el) {\n return el.state === \"home\";\n});\nreturn {\"payload\":{\"user1\":home?\"home\":\"away\"}};",
- "outputs": 1,
- "noerr": 0,
- "x": 620,
- "y": 40,
- "wires": [
- [
- "b4a281ad.7b804"
- ]
- ]
- },
- {
- "id": "c792d038.75f7b",
- "type": "function",
- "z": "194463a7.c501ac",
- "name": "set user2",
- "func": "var home = msg.payload[0].some(function(el) {\n return el.state === \"home\";\n});\nreturn {\"payload\":{\"user2\":home?\"home\":\"away\"}};",
- "outputs": 1,
- "noerr": 0,
- "x": 620,
- "y": 80,
- "wires": [
- [
- "b4a281ad.7b804"
- ]
- ]
- },
- {
- "id": "557cc62.b2a3638",
- "type": "switch",
- "z": "27a36387.d08f7c",
- "name": "was < 1500 before",
- "property": "$number(data.old_state.state)",
- "propertyType": "jsonata",
- "rules": [
- {
- "t": "lt",
- "v": "1500",
- "vt": "num"
- },
- {
- "t": "gte",
- "v": "1500",
- "vt": "num"
- }
- ],
- "checkall": "true",
- "repair": false,
- "outputs": 2,
- "x": 310,
- "y": 1040,
- "wires": [
- [
- "ef7f2fa0.deaf8"
- ],
- [
- "29183b1.7f300c4"
- ]
- ]
- },
- {
- "id": "22b2b366.d4ca5c",
- "type": "api-call-service",
- "z": "27a36387.d08f7c",
- "name": "co2 above 2000",
- "server": "aac717d.c0c40e8",
- "service_domain": "notify",
- "service": "",
- "data": "{ \"message\": \"Der CO₂-Wert ist über 2000ppm. Lebt ihr noch?\", \"data\": {\"inline_keyboard\":[\"Ja ich habe überlebt!:/still_alive\"]} }",
- "mergecontext": "",
- "x": 1100,
- "y": 1060,
- "wires": [
- []
- ]
- },
- {
- "id": "25dd1c10.12a8e4",
- "type": "api-call-service",
- "z": "27a36387.d08f7c",
- "name": "co2 above 1500",
- "server": "aac717d.c0c40e8",
- "service_domain": "notify",
- "service": "",
- "data": "{ \"message\": \"Der CO₂-Wert ist über 1500ppm. Bitte lüften!\" }",
- "mergecontext": "",
- "x": 880,
- "y": 1020,
- "wires": [
- []
- ]
- },
- {
- "id": "ef7f2fa0.deaf8",
- "type": "switch",
- "z": "27a36387.d08f7c",
- "name": "co2 is now >= 1500",
- "property": "$number(payload)",
- "propertyType": "jsonata",
- "rules": [
- {
- "t": "gte",
- "v": "1500",
- "vt": "num"
- }
- ],
- "checkall": "true",
- "repair": false,
- "outputs": 1,
- "x": 530,
- "y": 1020,
- "wires": [
- [
- "4fcbf9b0.9fc458"
- ]
- ]
- },
- {
- "id": "4b8c38f7.c1e408",
- "type": "switch",
- "z": "27a36387.d08f7c",
- "name": "co2 is now >= 2000",
- "property": "$number(payload)",
- "propertyType": "jsonata",
- "rules": [
- {
- "t": "gte",
- "v": "2000",
- "vt": "num"
- }
- ],
- "checkall": "true",
- "repair": false,
- "outputs": 1,
- "x": 750,
- "y": 1060,
- "wires": [
- [
- "388342b4.36d97e"
- ]
- ]
- },
- {
- "id": "29183b1.7f300c4",
- "type": "switch",
- "z": "27a36387.d08f7c",
- "name": "co2 was < 2000 before",
- "property": "$number(data.old_state.state)",
- "propertyType": "jsonata",
- "rules": [
- {
- "t": "lt",
- "v": "2000",
- "vt": "num"
- }
- ],
- "checkall": "true",
- "repair": false,
- "outputs": 1,
- "x": 540,
- "y": 1060,
- "wires": [
- [
- "4b8c38f7.c1e408"
- ]
- ]
- },
- {
- "id": "b08b59ed.c27e38",
- "type": "server-state-changed",
- "z": "27a36387.d08f7c",
- "name": "Living room CO2",
- "server": "aac717d.c0c40e8",
- "entityidfilter": "sensor.netatmo_indoor_co2",
- "entityidfiltertype": "exact",
- "haltifstate": "",
- "x": 100,
- "y": 1040,
- "wires": [
- [
- "557cc62.b2a3638"
- ]
- ]
- },
- {
- "id": "388342b4.36d97e",
- "type": "subflow:194463a7.c501ac",
- "z": "27a36387.d08f7c",
- "name": "",
- "x": 930,
- "y": 1060,
- "wires": [
- [
- "22b2b366.d4ca5c"
- ]
- ]
- },
- {
- "id": "4fcbf9b0.9fc458",
- "type": "subflow:194463a7.c501ac",
- "z": "27a36387.d08f7c",
- "name": "",
- "x": 710,
- "y": 1020,
- "wires": [
- [
- "25dd1c10.12a8e4"
- ]
- ]
- },
- {
- "id": "afcc1cae.4ca9e",
- "type": "server-events",
- "z": "27a36387.d08f7c",
- "name": "incoming data",
- "server": "aac717d.c0c40e8",
- "x": 90,
- "y": 560,
- "wires": [
- [
- "7160f9d7.feaa08",
- "ebb909f8.d606f8",
- "79606a20.4bc754"
- ]
- ]
- },
- {
- "id": "ebb909f8.d606f8",
- "type": "switch",
- "z": "27a36387.d08f7c",
- "name": "is telegram callback",
- "property": "payload.event_type",
- "propertyType": "msg",
- "rules": [
- {
- "t": "eq",
- "v": "telegram_callback",
- "vt": "str"
- }
- ],
- "checkall": "true",
- "outputs": 1,
- "x": 310,
- "y": 560,
- "wires": [
- [
- "7576db61.019664",
- "97051056.51fa3"
- ]
- ]
- },
- {
- "id": "7576db61.019664",
- "type": "switch",
- "z": "27a36387.d08f7c",
- "name": "/still_alive",
- "property": "payload.event.data",
- "propertyType": "msg",
- "rules": [
- {
- "t": "eq",
- "v": "/still_alive",
- "vt": "str"
- }
- ],
- "checkall": "true",
- "outputs": 1,
- "x": 520,
- "y": 560,
- "wires": [
- [
- "ac88f05d.dd03a",
- "a1037051.1dbc"
- ]
- ]
- },
- {
- "id": "ac88f05d.dd03a",
- "type": "function",
- "z": "27a36387.d08f7c",
- "name": "set callback answer",
- "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}",
- "outputs": 1,
- "noerr": 0,
- "x": 790,
- "y": 540,
- "wires": [
- [
- "37d77a7d.6302d6"
- ]
- ]
- },
- {
- "id": "a1037051.1dbc",
- "type": "function",
- "z": "27a36387.d08f7c",
- "name": "set edit message",
- "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}",
- "outputs": 1,
- "noerr": 0,
- "x": 790,
- "y": 580,
- "wires": [
- [
- "c4cf1cde.3858d"
- ]
- ]
- },
- {
- "id": "c4cf1cde.3858d",
- "type": "api-call-service",
- "z": "27a36387.d08f7c",
- "name": "edit message",
- "server": "aac717d.c0c40e8",
- "service_domain": "telegram_bot",
- "service": "edit_message",
- "data": "{}",
- "x": 1000,
- "y": 580,
- "wires": [
- []
- ]
- },
- {
- "id": "37d77a7d.6302d6",
- "type": "api-call-service",
- "z": "27a36387.d08f7c",
- "name": "send callback answer",
- "server": "aac717d.c0c40e8",
- "service_domain": "telegram_bot",
- "service": "answer_callback_query",
- "data": "{}",
- "x": 1020,
- "y": 540,
- "wires": [
- []
- ]
- },
- {
- "id": "aac717d.c0c40e8",
- "type": "server",
- "z": "",
- "name": "Home Assistant"
- }
- ]
Add Comment
Please, Sign In to add comment