离家场景【一键查询处于开启中的设备】【子流程】

场景简述

  1. 关闭门口灯时, 查询所有处于开启的设备, 收到第一条消息过1秒汇总
  2. 通过子流程 播报当前时间
  3. 播报处于开启状态的设备名称

[
    {
        "id": "20ea2e77.86d7e2",
        "type": "subflow",
        "name": "判断时间段",
        "info": "## 判断时间段\n1. 判断当前时间段,早上/下午/晚上\n2. 输出相应问候语到msg.timerange\n3. 输出当前时间到msg.time  如12:54",
        "category": "",
        "in": [
            {
                "x": 540,
                "y": 260,
                "wires": [
                    {
                        "id": "c01f320f.98b2d"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 1440,
                "y": 260,
                "wires": [
                    {
                        "id": "72157f04.69de8",
                        "port": 0
                    }
                ]
            }
        ],
        "env": []
    },
    {
        "id": "c01f320f.98b2d",
        "type": "function",
        "z": "20ea2e77.86d7e2",
        "name": "判断时间段",
        "func": "\nvar before_dawn = ['你见过凌晨四点的洛杉矶吗?','夜深了,早点休息'];\nvar morning = ['早上好','早安','早啊','早','Good morning','早上好,送你清新的问候'];\nvar noon = ['中午好','午安','good afternoon'];\nvar afternoon = ['下午好','午安','Good afternoon'];\nvar night = ['晚上好','宁静的夜晚,美丽的天空,丝丝的微风','万家灯火,是夜晚最美的风景'];\nfunction rnd(start, end){\n    return Math.floor(Math.random() * (end - start) + start);\n}\nvar now = new Date();\nvar hour = now.getHours();\nif (hour >= 0 && hour < 5){\n    msg.timerange = before_dawn[rnd(0,before_dawn.length)];\n}\nelse if (hour >= 5 && hour < 11){\n    msg.timerange = morning[rnd(0,morning.length)];\n}\nelse if (hour >=11 && hour < 13){\n    msg.timerange = noon[rnd(0,noon.length)];\n}\nelse if (hour >= 13 && hour < 18){\n    msg.timerange = afternoon[rnd(0,afternoon.length)];\n}\nelse if (hour >= 18 && hour < 24){\n    msg.timerange = night[rnd(0,night.length)];\n}\nelse {\n    msg.timerange = '你好';\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 710,
        "y": 260,
        "wires": [
            [
                "c74d1a66.b47138"
            ]
        ]
    },
    {
        "id": "c74d1a66.b47138",
        "type": "function",
        "z": "20ea2e77.86d7e2",
        "name": "获取当前时间戳",
        "func": "var now = new Date();\nvar timestamp = Date.parse(new Date());\nmsg.timestamp = timestamp;\nreturn msg",
        "outputs": 1,
        "noerr": 0,
        "x": 940,
        "y": 240,
        "wires": [
            [
                "72157f04.69de8"
            ]
        ]
    },
    {
        "id": "72157f04.69de8",
        "type": "moment",
        "z": "20ea2e77.86d7e2",
        "name": "转换时间格式",
        "topic": "",
        "input": "timestamp",
        "inputType": "msg",
        "inTz": "Asia/Shanghai",
        "adjAmount": 0,
        "adjType": "days",
        "adjDir": "add",
        "format": "HH:mm",
        "locale": "C",
        "output": "time",
        "outputType": "msg",
        "outTz": "Asia/Shanghai",
        "x": 1200,
        "y": 240,
        "wires": [
            []
        ]
    },
    {
        "id": "63a4c550.152e4c",
        "type": "debug",
        "z": "8d3e5e26.c7e32",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 1610,
        "y": 620,
        "wires": []
    },
    {
        "id": "ed723030.65d91",
        "type": "ioBroker get",
        "z": "8d3e5e26.c7e32",
        "name": "主卧灯",
        "topic": "mihome.0.devices.ctrl_ln1_aq1_158d0002325353.channel_0",
        "attrname": "payload",
        "payloadType": "value",
        "x": 810,
        "y": 520,
        "wires": [
            [
                "bd914a82.7e3228"
            ]
        ]
    },
    {
        "id": "697173cf.e6124c",
        "type": "join",
        "z": "8d3e5e26.c7e32",
        "name": "",
        "mode": "custom",
        "build": "string",
        "property": "content",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": false,
        "timeout": "1",
        "count": "",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "num",
        "reduceFixup": "",
        "x": 1330,
        "y": 720,
        "wires": [
            [
                "e18d908a.9e475"
            ]
        ]
    },
    {
        "id": "f394f2ef.3c512",
        "type": "ioBroker get",
        "z": "8d3e5e26.c7e32",
        "name": "浴室光管",
        "topic": "mihome.0.devices.ctrl_ln2_aq1_158d000239c207.channel_0",
        "attrname": "payload",
        "payloadType": "value",
        "x": 820,
        "y": 560,
        "wires": [
            [
                "58b3191a.ba0c08"
            ]
        ]
    },
    {
        "id": "3a8c7b41.98e1d4",
        "type": "ioBroker get",
        "z": "8d3e5e26.c7e32",
        "name": "浴室led",
        "topic": "mihome.0.devices.ctrl_ln2_aq1_158d000239c207.channel_1",
        "attrname": "payload",
        "payloadType": "value",
        "x": 820,
        "y": 600,
        "wires": [
            [
                "45194643.c7a228"
            ]
        ]
    },
    {
        "id": "5c0ead2a.d07154",
        "type": "ioBroker get",
        "z": "8d3e5e26.c7e32",
        "name": "书房射灯",
        "topic": "mihome.0.devices.ctrl_ln2_aq1_158d000239c546.channel_0",
        "attrname": "payload",
        "payloadType": "value",
        "x": 820,
        "y": 640,
        "wires": [
            [
                "93bf6b7c.229158"
            ]
        ]
    },
    {
        "id": "66ba4165.978ca",
        "type": "ioBroker get",
        "z": "8d3e5e26.c7e32",
        "name": "书房吊灯",
        "topic": "mihome.0.devices.ctrl_ln2_aq1_158d000239c546.channel_1",
        "attrname": "payload",
        "payloadType": "value",
        "x": 820,
        "y": 680,
        "wires": [
            [
                "44654d26.41b184"
            ]
        ]
    },
    {
        "id": "ed4dd8de.21fc68",
        "type": "ioBroker get",
        "z": "8d3e5e26.c7e32",
        "name": "阳台排气扇",
        "topic": "mihome.0.devices.ctrl_ln2_aq1_158d00024d6356.channel_0",
        "attrname": "payload",
        "payloadType": "value",
        "x": 830,
        "y": 720,
        "wires": [
            [
                "11c7ef8d.297c6"
            ]
        ]
    },
    {
        "id": "5ba43fa1.4c237",
        "type": "ioBroker get",
        "z": "8d3e5e26.c7e32",
        "name": "洗衣灯",
        "topic": "mihome.0.devices.ctrl_ln2_aq1_158d00024d6356.channel_1",
        "attrname": "payload",
        "payloadType": "value",
        "x": 810,
        "y": 760,
        "wires": [
            [
                "a055c3ec.4e416"
            ]
        ]
    },
    {
        "id": "af6f3a33.5d9d18",
        "type": "ioBroker get",
        "z": "8d3e5e26.c7e32",
        "name": "阳台灯",
        "topic": "mihome.0.devices.ctrl_ln2_aq1_158d00024efc9e.channel_0",
        "attrname": "payload",
        "payloadType": "value",
        "x": 810,
        "y": 800,
        "wires": [
            [
                "cfa484fc.9e3c68"
            ]
        ]
    },
    {
        "id": "fa7d0a1d.726e78",
        "type": "ioBroker get",
        "z": "8d3e5e26.c7e32",
        "name": "卧室灯",
        "topic": "mihome.0.devices.ctrl_ln2_aq1_158d00024efc9e.channel_1",
        "attrname": "payload",
        "payloadType": "value",
        "x": 810,
        "y": 840,
        "wires": [
            [
                "22e12c9a.fdd754"
            ]
        ]
    },
    {
        "id": "71d86e4a.23113",
        "type": "ioBroker get",
        "z": "8d3e5e26.c7e32",
        "name": "厨房灯",
        "topic": "mihome.0.devices.ctrl_ln2_aq1_158d00024efd51.channel_0",
        "attrname": "payload",
        "payloadType": "value",
        "x": 810,
        "y": 880,
        "wires": [
            [
                "df96a465.c75ea8"
            ]
        ]
    },
    {
        "id": "698b0bc4.f2c9a4",
        "type": "ioBroker get",
        "z": "8d3e5e26.c7e32",
        "name": "厨房光管",
        "topic": "mihome.0.devices.ctrl_ln2_aq1_158d00024efd51.channel_1",
        "attrname": "payload",
        "payloadType": "value",
        "x": 820,
        "y": 920,
        "wires": [
            [
                "865d58f6.ceffa8"
            ]
        ]
    },
    {
        "id": "ffdf39cf.18c1a8",
        "type": "ioBroker get",
        "z": "8d3e5e26.c7e32",
        "name": "客厅左键灯",
        "topic": "mihome.0.devices.ctrl_neutral2_158d00014cf47a.channel_0",
        "attrname": "payload",
        "payloadType": "value",
        "x": 830,
        "y": 960,
        "wires": [
            [
                "1acafa86.e78aa5"
            ]
        ]
    },
    {
        "id": "43b6e3ac.817e7c",
        "type": "ioBroker get",
        "z": "8d3e5e26.c7e32",
        "name": "客厅右键灯",
        "topic": "mihome.0.devices.ctrl_neutral2_158d00014cf47a.channel_1",
        "attrname": "payload",
        "payloadType": "value",
        "x": 830,
        "y": 1000,
        "wires": [
            [
                "a22ab87d.d87dc8"
            ]
        ]
    },
    {
        "id": "dacb02cd.6a421",
        "type": "ioBroker get",
        "z": "8d3e5e26.c7e32",
        "name": "副厅灯",
        "topic": "mihome.0.devices.ctrl_ln1_aq1_158d0001fd43d1.channel_0",
        "attrname": "payload",
        "payloadType": "value",
        "x": 810,
        "y": 420,
        "wires": [
            [
                "94a7b398.fc46b",
                "f68a043c.ee8268"
            ]
        ]
    },
    {
        "id": "8224ea37.306ac8",
        "type": "ioBroker get",
        "z": "8d3e5e26.c7e32",
        "name": "房间灯",
        "topic": "mihome.0.devices.ctrl_ln1_aq1_158d0002114e41.channel_0",
        "attrname": "payload",
        "payloadType": "value",
        "x": 810,
        "y": 480,
        "wires": [
            [
                "682b66fd.e83cf8"
            ]
        ]
    },
    {
        "id": "94a7b398.fc46b",
        "type": "function",
        "z": "8d3e5e26.c7e32",
        "name": "获取开关名称",
        "func": "if(msg.payload==='true'){\n    msg.content = '副厅灯,';\n    return msg;\n}\nelse if(msg.payload==='false'){\n    return null;\n    //msg.content = {'name':'副厅灯','state':'关闭'};\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1020,
        "y": 420,
        "wires": [
            [
                "697173cf.e6124c"
            ]
        ]
    },
    {
        "id": "682b66fd.e83cf8",
        "type": "function",
        "z": "8d3e5e26.c7e32",
        "name": "获取开关名称",
        "func": "if(msg.payload==='true'){\n    msg.content = '房间灯,';\n    return msg;\n}\nelse if(msg.payload==='false'){\n    return null;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1020,
        "y": 480,
        "wires": [
            [
                "697173cf.e6124c"
            ]
        ]
    },
    {
        "id": "bd914a82.7e3228",
        "type": "function",
        "z": "8d3e5e26.c7e32",
        "name": "获取开关名称",
        "func": "if(msg.payload==='true'){\n    msg.content = '主卧灯,';\n    return msg;\n}\nelse if(msg.payload==='false'){\n    return null;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1020,
        "y": 520,
        "wires": [
            [
                "697173cf.e6124c"
            ]
        ]
    },
    {
        "id": "58b3191a.ba0c08",
        "type": "function",
        "z": "8d3e5e26.c7e32",
        "name": "获取开关名称",
        "func": "if(msg.payload==='true'){\n    msg.content = '浴室光管,';\n    return msg;\n}\nelse if(msg.payload==='false'){\n    return null;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1020,
        "y": 560,
        "wires": [
            [
                "697173cf.e6124c"
            ]
        ]
    },
    {
        "id": "fe23bd6.705354",
        "type": "function",
        "z": "8d3e5e26.c7e32",
        "name": "输出TTS内容",
        "func": "msg.payload = `${msg.timerange},现在是${msg.time},以下灯处于开启状态{msg.content}`;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 1670,
        "y": 720,
        "wires": [
            [
                "63a4c550.152e4c",
                "6b7d1278.ecb91c"
            ]
        ]
    },
    {
        "id": "45194643.c7a228",
        "type": "function",
        "z": "8d3e5e26.c7e32",
        "name": "获取开关名称",
        "func": "if(msg.payload==='true'){\n    msg.content = '浴室led,';\n    return msg;\n}\nelse if(msg.payload==='false'){\n    return null;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1020,
        "y": 600,
        "wires": [
            [
                "697173cf.e6124c"
            ]
        ]
    },
    {
        "id": "93bf6b7c.229158",
        "type": "function",
        "z": "8d3e5e26.c7e32",
        "name": "获取开关名称",
        "func": "if(msg.payload==='true'){\n    msg.content = '书房射灯,';\n    return msg;\n}\nelse if(msg.payload==='false'){\n    return null;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1020,
        "y": 640,
        "wires": [
            [
                "697173cf.e6124c"
            ]
        ]
    },
    {
        "id": "44654d26.41b184",
        "type": "function",
        "z": "8d3e5e26.c7e32",
        "name": "获取开关名称",
        "func": "if(msg.payload==='true'){\n    msg.content = '书房吊灯,';\n    return msg;\n}\nelse if(msg.payload==='false'){\n    return null;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1020,
        "y": 680,
        "wires": [
            [
                "697173cf.e6124c"
            ]
        ]
    },
    {
        "id": "11c7ef8d.297c6",
        "type": "function",
        "z": "8d3e5e26.c7e32",
        "name": "获取开关名称",
        "func": "if(msg.payload==='true'){\n    msg.content = '阳台排气扇,';\n    return msg;\n}\nelse if(msg.payload==='false'){\n    return null;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1020,
        "y": 720,
        "wires": [
            [
                "697173cf.e6124c"
            ]
        ]
    },
    {
        "id": "a055c3ec.4e416",
        "type": "function",
        "z": "8d3e5e26.c7e32",
        "name": "获取开关名称",
        "func": "if(msg.payload==='true'){\n    msg.content = '洗衣灯,';\n    return msg;\n}\nelse if(msg.payload==='false'){\n    return null;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1020,
        "y": 760,
        "wires": [
            [
                "697173cf.e6124c"
            ]
        ]
    },
    {
        "id": "cfa484fc.9e3c68",
        "type": "function",
        "z": "8d3e5e26.c7e32",
        "name": "获取开关名称",
        "func": "if(msg.payload==='true'){\n    msg.content = '阳台灯,';\n    return msg;\n}\nelse if(msg.payload==='false'){\n    return null;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1020,
        "y": 800,
        "wires": [
            [
                "697173cf.e6124c"
            ]
        ]
    },
    {
        "id": "22e12c9a.fdd754",
        "type": "function",
        "z": "8d3e5e26.c7e32",
        "name": "获取开关名称",
        "func": "if(msg.payload==='true'){\n    msg.content = '卧室灯,';\n    return msg;\n}\nelse if(msg.payload==='false'){\n    return null;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1020,
        "y": 840,
        "wires": [
            [
                "697173cf.e6124c"
            ]
        ]
    },
    {
        "id": "df96a465.c75ea8",
        "type": "function",
        "z": "8d3e5e26.c7e32",
        "name": "获取开关名称",
        "func": "if(msg.payload==='true'){\n    msg.content = '厨房灯,';\n    return msg;\n}\nelse if(msg.payload==='false'){\n    return null;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1020,
        "y": 880,
        "wires": [
            [
                "697173cf.e6124c"
            ]
        ]
    },
    {
        "id": "865d58f6.ceffa8",
        "type": "function",
        "z": "8d3e5e26.c7e32",
        "name": "获取开关名称",
        "func": "if(msg.payload==='true'){\n    msg.content = '厨房光管,';\n    return msg;\n}\nelse if(msg.payload==='false'){\n    return null;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1020,
        "y": 920,
        "wires": [
            [
                "697173cf.e6124c"
            ]
        ]
    },
    {
        "id": "1acafa86.e78aa5",
        "type": "function",
        "z": "8d3e5e26.c7e32",
        "name": "获取开关名称",
        "func": "if(msg.payload==='true'){\n    msg.content = '客厅左键灯,';\n    return msg;\n}\nelse if(msg.payload==='false'){\n    return null;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1020,
        "y": 960,
        "wires": [
            [
                "697173cf.e6124c"
            ]
        ]
    },
    {
        "id": "a22ab87d.d87dc8",
        "type": "function",
        "z": "8d3e5e26.c7e32",
        "name": "获取开关名称",
        "func": "if(msg.payload==='true'){\n    msg.content = '客厅右键灯,';\n    return msg;\n}\nelse if(msg.payload==='false'){\n    return null;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1020,
        "y": 1000,
        "wires": [
            [
                "697173cf.e6124c"
            ]
        ]
    },
    {
        "id": "599a9fc3.9b682",
        "type": "ioBroker in",
        "z": "8d3e5e26.c7e32",
        "name": "客厅右键",
        "topic": "mihome.0.devices.ctrl_neutral2_158d00014cf47a.channel_1",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 60,
        "y": 540,
        "wires": [
            [
                "974b00da.5f6a5",
                "c96ed60f.b4edd8"
            ]
        ]
    },
    {
        "id": "974b00da.5f6a5",
        "type": "debug",
        "z": "8d3e5e26.c7e32",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 230,
        "y": 600,
        "wires": []
    },
    {
        "id": "c96ed60f.b4edd8",
        "type": "switch",
        "z": "8d3e5e26.c7e32",
        "name": "过滤非即时更新的消息",
        "property": "timestamp",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "lastchange",
                "vt": "msg"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 260,
        "y": 540,
        "wires": [
            [
                "7881ea4d.cfa584"
            ]
        ]
    },
    {
        "id": "7881ea4d.cfa584",
        "type": "switch",
        "z": "8d3e5e26.c7e32",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "false",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 470,
        "y": 700,
        "wires": [
            [],
            [
                "dacb02cd.6a421",
                "8224ea37.306ac8",
                "ed723030.65d91",
                "f394f2ef.3c512",
                "3a8c7b41.98e1d4",
                "5c0ead2a.d07154",
                "66ba4165.978ca",
                "ed4dd8de.21fc68",
                "5ba43fa1.4c237",
                "af6f3a33.5d9d18",
                "fa7d0a1d.726e78",
                "71d86e4a.23113",
                "698b0bc4.f2c9a4",
                "ffdf39cf.18c1a8",
                "43b6e3ac.817e7c"
            ]
        ]
    },
    {
        "id": "e18d908a.9e475",
        "type": "subflow:20ea2e77.86d7e2",
        "z": "8d3e5e26.c7e32",
        "name": "",
        "x": 1490,
        "y": 720,
        "wires": [
            [
                "fe23bd6.705354"
            ]
        ]
    },
    {
        "id": "f68a043c.ee8268",
        "type": "debug",
        "z": "8d3e5e26.c7e32",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 990,
        "y": 360,
        "wires": []
    },
    {
        "id": "4e5f2755.342858",
        "type": "comment",
        "z": "8d3e5e26.c7e32",
        "name": "一键播报处于开启状态的灯",
        "info": "",
        "x": 130,
        "y": 480,
        "wires": []
    }
]

这个不错哦。

学习学习

请问如何删除子流程啊

子流程 在界面左侧,跟那些节点一起,在最上面,双击进入子流程编辑界面,在tab上有删除子流程的按钮