『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
楼主: lidicn

[流程系列] 回家场景【播报室内温湿度】【谚语格言】

  [复制链接]

1

主题

14

帖子

166

积分

注册会员

Rank: 2

积分
166
金钱
152
HASS币
0
发表于 2024-9-23 17:26:53 | 显示全部楼层
楼主厉害,谢谢分享
回复

使用道具 举报

1

主题

24

帖子

129

积分

注册会员

Rank: 2

积分
129
金钱
105
HASS币
0
发表于 2024-9-24 17:48:00 | 显示全部楼层
学习学习
回复

使用道具 举报

5

主题

21

帖子

120

积分

注册会员

Rank: 2

积分
120
金钱
99
HASS币
0
发表于 2024-9-25 21:13:43 | 显示全部楼层
谢谢分享。学习知识。
回复

使用道具 举报

0

主题

43

帖子

174

积分

注册会员

Rank: 2

积分
174
金钱
131
HASS币
0
发表于 2024-9-26 16:39:57 | 显示全部楼层
学习学习
回复

使用道具 举报

1

主题

24

帖子

129

积分

注册会员

Rank: 2

积分
129
金钱
105
HASS币
0
发表于 2024-9-26 17:14:31 | 显示全部楼层
[{"id":"a3997102.a99ae","type":"function","z":"bdf6fb07.64fd48","name":"保存格言到flow变量","func":"flow.set('wisdom',msg.payload.info + msg.payload.author);\nreturn null;","outputs":0,"noerr":0,"x":2530,"y":4220,"wires":[]},{"id":"f06e376.5aeb3c8","type":"inject","z":"bdf6fb07.64fd48","name":"每小时获取一次名言","topic":"","payload":"{}","payloadType":"json","repeat":"3600","crontab":"","once":true,"onceDelay":0.1,"x":1920,"y":4220,"wires":[["7cb2402.cc4ffc"]]},{"id":"2059008f.5f398","type":"comment","z":"bdf6fb07.64fd48","name":"获取名言flow变量","info":"flow变量名为 token\n获取方法 msg.access_token = flow.get('token');","x":1897.8333282470703,"y":4175.666561126709,"wires":[]},{"id":"7cb2402.cc4ffc","type":"http request","z":"bdf6fb07.64fd48","name":"名言api","method":"GET","ret":"txt","url":"http://api.bunian.cn/yulu/?fun=json","tls":"","x":2160,"y":4220,"wires":[["890e20cf.7c3a8"]]},{"id":"890e20cf.7c3a8","type":"json","z":"bdf6fb07.64fd48","name":"","property":"payload","action":"","pretty":false,"x":2350,"y":4220,"wires":[["a3997102.a99ae"]]},{"id":"7f426214.3934ac","type":"api-current-state","z":"bdf6fb07.64fd48","name":"获取室内温度","server":"94f0c0a9.629b6","outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"sensor.temperature_158d0000fd539c","state_type":"str","override_payload":true,"override_data":true,"x":2880,"y":4320,"wires":[["3be3eef7.4d5332","aa8942b8.c7e5c"]]},{"id":"48b9cd54.e89c84","type":"api-current-state","z":"bdf6fb07.64fd48","name":"获取室内湿度","server":"94f0c0a9.629b6","outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"sensor.humidity_158d0000fd539c","state_type":"str","override_payload":true,"override_data":true,"x":2880,"y":4380,"wires":[["d1a55952.33b9d8"]]},{"id":"3be3eef7.4d5332","type":"function","z":"bdf6fb07.64fd48","name":"温度","func":"var result='';\nif(msg.data.state>=23){\n  result = msg.data.state + '摄氏度,炎热'; \n}\nelse if(msg.data.state>=18 && msg.data.state<=23){\n  result = msg.data.state + '摄氏度,舒适'; \n}\nelse if(msg.data.state>12 && msg.data.state<18){\n    result = msg.data.state + '摄氏度,较冷';\n}\nelse{\n    result = msg.data.state + '摄氏度,寒冷,请注意保暖';\n}\n\nmsg.payload = {"temperature":result};\nreturn msg;","outputs":1,"noerr":0,"x":3070,"y":4320,"wires":[["d1c941a9.52593"]]},{"id":"d1a55952.33b9d8","type":"function","z":"bdf6fb07.64fd48","name":"湿度","func":"var result='';\nif(msg.data.state>=60){\n  result = msg.data.state + '潮湿'; \n}\nelse if(msg.data.state>30 && msg.data.state<60){\n    result = msg.data.state + '适中';\n}\nelse{\n    result = msg.data.state + '干燥';\n}\nmsg.payload = {"humidity":result};\nreturn msg;","outputs":1,"noerr":0,"x":3070,"y":4380,"wires":[["d1c941a9.52593"]]},{"id":"a583519b.c8397","type":"api-call-service","z":"bdf6fb07.64fd48","name":"小爱TTS","server":"94f0c0a9.629b6","service_domain":"hello_miai","service":"add2msgqueue","data":"","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":3640,"y":4360,"wires":[[]]},{"id":"1bfadb64.9eb5a5","type":"function","z":"bdf6fb07.64fd48","name":"TTS内容","func":"var wisdom = flow.get('wisdom');\n\n\nvar message = `欢迎回家:现在室内温度${msg.payload.temperature},湿度为百分之${msg.payload.humidity}。${wisdom}`;\nmsg.payload = {};\nmsg.payload.data = {"message":message,"miai_num":"0"};\nreturn msg;","outputs":1,"noerr":0,"x":3420,"y":4360,"wires":[["a583519b.c8397","71d25351.12058c"]]},{"id":"d1c941a9.52593","type":"join","z":"bdf6fb07.64fd48","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":3270,"y":4360,"wires":[["1bfadb64.9eb5a5"]]},{"id":"71d25351.12058c","type":"debug","z":"bdf6fb07.64fd48","name":"调式信息","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":3620,"y":4420,"wires":[]},{"id":"7051732.489678c","type":"server-state-changed","z":"bdf6fb07.64fd48","name":"监测大门状态","server":"94f0c0a9.629b6","entityidfilter":"binary_sensor.door_window_sensor_158d0000d6de14","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":1870,"y":4400,"wires":[["b0d0837f.90c33"]]},{"id":"f2134b3d.fcfde8","type":"switch","z":"bdf6fb07.64fd48","name":"大门新状态为开启","property":"data.new_state.state","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":2330,"y":4400,"wires":[["3ae5dab8.d82b16"]]},{"id":"b0d0837f.90c33","type":"switch","z":"bdf6fb07.64fd48","name":"大门原状态为关闭","property":"data.old_state.state","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":2110,"y":4400,"wires":[["f2134b3d.fcfde8"]]},{"id":"45d250f3.aa2a6","type":"api-current-state","z":"bdf6fb07.64fd48","name":"获取客厅光照度","server":"94f0c0a9.629b6","outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"sensor.illumination_158d0001a2520d","state_type":"str","override_payload":true,"override_data":true,"x":2880,"y":4440,"wires":[["c72b5594.329e38"]]},{"id":"c72b5594.329e38","type":"switch","z":"bdf6fb07.64fd48","name":"低于20lx","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"20.0","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":3100,"y":4440,"wires":[["80610ff5.d5bb8"]]},{"id":"80610ff5.d5bb8","type":"api-call-service","z":"bdf6fb07.64fd48","name":"打开客厅灯","server":"94f0c0a9.629b6","service_domain":"switch","service":"turn_on","data":"{"entity_id":"switch.wall_switch_right_158d00014cf47a"}","render_data":false,"mergecontext":"","x":3290,"y":4440,"wires":[[]]},{"id":"9c104446.36be18","type":"api-call-service","z":"bdf6fb07.64fd48","name":"小爱TTS","server":"94f0c0a9.629b6","service_domain":"hello_miai","service":"add2msgqueue","data":"","render_data":false,"mergecontext":"","x":3220,"y":4540,"wires":[[]]},{"id":"44aea020.1882d","type":"function","z":"bdf6fb07.64fd48","name":"推送内容","func":"var message = flow.get('wisdom');\n\nmsg.payload = {};\nmsg.payload.data = {"message":message,"miai_num":"0"};\nreturn msg;\n","outputs":1,"noerr":0,"x":2880,"y":4540,"wires":[["83b8982b.a5dae8"]]},{"id":"83b8982b.a5dae8","type":"trigger","z":"bdf6fb07.64fd48","op1":"","op2":"","op1type":"pay","op2type":"nul","duration":"10","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":3050,"y":4540,"wires":[["9c104446.36be18"]]},{"id":"ea2db4d3.5c92b8","type":"comment","z":"bdf6fb07.64fd48","name":"开门播报室内温湿度","info":"","x":1897.7777709960938,"y":4334.4443359375,"wires":[]},{"id":"3ae5dab8.d82b16","type":"api-current-state","z":"bdf6fb07.64fd48","name":"防盗门状态","server":"94f0c0a9.629b6","outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"binary_sensor.door_window_sensor_158d0001f34db6","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":2490,"y":4320,"wires":[["2deae646.e72e1a"]]},{"id":"2deae646.e72e1a","type":"switch","z":"bdf6fb07.64fd48","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":2630,"y":4380,"wires":[["7f426214.3934ac","48b9cd54.e89c84","45d250f3.aa2a6"],["44aea020.1882d"]]},{"id":"aa8942b8.c7e5c","type":"debug","z":"bdf6fb07.64fd48","name":"调式信息","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":3040,"y":4260,"wires":[]},{"id":"94f0c0a9.629b6","type":"server","z":"","name":"Home Assistant","legacy":true,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open"}]

新版本,可以导入的,大家可以参考下。
回复

使用道具 举报

4

主题

101

帖子

482

积分

中级会员

Rank: 3Rank: 3

积分
482
金钱
381
HASS币
0
发表于 2024-9-29 14:05:02 | 显示全部楼层
本帖最后由 louwu 于 2024-9-29 20:42 编辑

[
    {
        "id": "a3997102.a99ae",
        "type": "function",
        "z": "bdf6fb07.64fd48",
        "name": "保存格言到flow变量",
        "func": "flow.set('wisdom', msg.payload.info + ' ' + msg.payload.author);\nreturn null;",
        "outputs": 0,
        "noerr": 0,
        "x": 2530,
        "y": 4220,
        "wires": []
    },
    {
        "id": "f06e376.5aeb3c8",
        "type": "inject",
        "z": "bdf6fb07.64fd48",
        "name": "每小时获取一次名言",
        "topic": "",
        "payload": "{}",
        "payloadType": "json",
        "repeat": "3600",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "x": 1920,
        "y": 4220,
        "wires": [
            [
                "7cb2402.cc4ffc"
            ]
        ]
    },
    {
        "id": "2059008f.5f398",
        "type": "comment",
        "z": "bdf6fb07.64fd48",
        "name": "获取名言flow变量",
        "info": "flow变量名为 wisdom\n获取方法 msg.wisdom = flow.get('wisdom');",
        "x": 1897.8333282470703,
        "y": 4175.666561126709,
        "wires": []
    },
    {
        "id": "7cb2402.cc4ffc",
        "type": "http request",
        "z": "bdf6fb07.64fd48",
        "name": "名言api",
        "method": "GET",
        "ret": "txt",
        "url": "http://api.bunian.cn/yulu/?fun=json",
        "tls": "",
        "x": 2160,
        "y": 4220,
        "wires": [
            [
                "890e20cf.7c3a8"
            ]
        ]
    },
    {
        "id": "890e20cf.7c3a8",
        "type": "json",
        "z": "bdf6fb07.64fd48",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 2350,
        "y": 4220,
        "wires": [
            [
                "a3997102.a99ae"
            ]
        ]
    },
    {
        "id": "7f426214.3934ac",
        "type": "api-current-state",
        "z": "bdf6fb07.64fd48",
        "name": "获取室内温度",
        "server": "94f0c0a9.629b6",
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": true,
        "entity_id": "sensor.temperature_158d0000fd539c",
        "state_type": "str",
        "override_payload": true,
        "override_data": true,
        "x": 2880,
        "y": 4320,
        "wires": [
            [
                "3be3eef7.4d5332",
                "aa8942b8.c7e5c"
            ]
        ]
    },
    {
        "id": "48b9cd54.e89c84",
        "type": "api-current-state",
        "z": "bdf6fb07.64fd48",
        "name": "获取室内湿度",
        "server": "94f0c0a9.629b6",
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": true,
        "entity_id": "sensor.humidity_158d0000fd539c",
        "state_type": "str",
        "override_payload": true,
        "override_data": true,
        "x": 2880,
        "y": 4380,
        "wires": [
            [
                "d1a55952.33b9d8"
            ]
        ]
    },
    {
        "id": "3be3eef7.4d5332",
        "type": "function",
        "z": "bdf6fb07.64fd48",
        "name": "温度",
        "func": "var result = '';\nif (msg.payload >= 23) {\n  result = msg.payload + '摄氏度, 炎热';\n} else if (msg.payload >= 18 && msg.payload < 23) {\n  result = msg.payload + '摄氏度, 舒适';\n} else if (msg.payload > 12 && msg.payload < 18) {\n  result = msg.payload + '摄氏度, 较冷';\n} else {\n  result = msg.payload + '摄氏度, 寒冷, 请注意保暖';\n}\nmsg.payload = {\"temperature\": result};\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 3070,
        "y": 4320,
        "wires": [
            [
                "d1c941a9.52593"
            ]
        ]
    },
    {
        "id": "d1a55952.33b9d8",
        "type": "function",
        "z": "bdf6fb07.64fd48",
        "name": "湿度",
        "func": "var result = '';\nif (msg.payload >= 60) {\n  result = msg.payload + '潮湿';\n} else if (msg.payload > 30 && msg.payload < 60) {\n  result = msg.payload + '适中';\n} else {\n  result = msg.payload + '干燥';\n}\nmsg.payload = {\"humidity\": result};\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 3070,
        "y": 4380,
        "wires": [
            [
                "d1c941a9.52593"
            ]
        ]
    },
    {
        "id": "a583519b.c8397",
        "type": "api-call-service",
        "z": "bdf6fb07.64fd48",
        "name": "小爱TTS",
        "server": "94f0c0a9.629b6",
        "service_domain": "hello_miai",
        "service": "add2msgqueue",
        "data": "",
        "render_data": false,
        "mergecontext": "",
        "output_location": "payload",
        "output_location_type": "msg",
        "x": 3640,
        "y": 4360,
        "wires": []
    },
    {
        "id": "1bfadb64.9eb5a5",
        "type": "function",
        "z": "bdf6fb07.64fd48",
        "name": "TTS内容",
        "func": "var wisdom = flow.get('wisdom') || '';\nvar message = `欢迎回家:现在室内温度 ${msg.payload.temperature},湿度为 ${msg.payload.humidity}%。 ${wisdom}`;\nmsg.payload = {};\nmsg.payload.data = {\"message\": message, \"miai_num\": \"0\"};\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 3420,
        "y": 4360,
        "wires": [
            [
                "a583519b.c8397",
                "71d25351.12058c"
            ]
        ]
    },
    {
        "id": "d1c941a9.52593",
        "type": "join",
        "z": "bdf6fb07.64fd48",
        "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": 3270,
        "y": 4360,
        "wires": [
            [
                "1bfadb64.9eb5a5"
            ]
        ]
    },
    {
        "id": "71d25351.12058c",
        "type": "debug",
        "z": "bdf6fb07.64fd48",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "x": 3660,
        "y": 4460,
        "wires": []
    },
    {
        "id": "380bd9af.0fef56",
        "type": "api-current-state",
        "z": "bdf6fb07.64fd48",
        "name": "获取客厅光照",
        "server": "94f0c0a9.629b6",
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": true,
        "entity_id": "sensor.lumi_lumi_sensor_lux_aq2_illumination",
        "state_type": "str",
        "override_payload": true,
        "override_data": true,
        "x": 1910,
        "y": 4800,
        "wires": [
            [
                "a00a8d86.4303b"
            ]
        ]
    },
    {
        "id": "a00a8d86.4303b",
        "type": "switch",
        "z": "bdf6fb07.64fd48",
        "name": "<20lx",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "lt",
                "v": "20",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 2100,
        "y": 4800,
        "wires": [
            [
                "99c98483.3ff808"
            ]
        ]
    },
    {
        "id": "99c98483.3ff808",
        "type": "api-call-service",
        "z": "bdf6fb07.64fd48",
        "name": "打开客厅灯",
        "server": "94f0c0a9.629b6",
        "service_domain": "switch",
        "service": "turn_on",
        "data": "{\"entity_id\":\"switch.lumi_lumi_relay_1\"}",
        "render_data": false,
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "x": 2250,
        "y": 4800,
        "wires": []
    },
    {
        "id": "94f0c0a9.629b6",
        "type": "server",
        "name": "Home Assistant",
        "addon": true
    }
]
回复

使用道具 举报

0

主题

9

帖子

60

积分

注册会员

Rank: 2

积分
60
金钱
51
HASS币
0
发表于 2024-10-16 10:17:32 | 显示全部楼层
多谢分享
回复

使用道具 举报

1

主题

18

帖子

86

积分

注册会员

Rank: 2

积分
86
金钱
68
HASS币
0
发表于 2024-10-23 11:36:32 | 显示全部楼层
太感谢了
回复

使用道具 举报

0

主题

6

帖子

36

积分

新手上路

Rank: 1

积分
36
金钱
30
HASS币
0
发表于 2024-10-24 16:25:41 | 显示全部楼层
谢谢分享啊

回复

使用道具 举报

0

主题

43

帖子

153

积分

注册会员

Rank: 2

积分
153
金钱
110
HASS币
0
发表于 2024-10-27 23:02:52 | 显示全部楼层
学习一下,谢谢分享
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-25 04:44 , Processed in 0.216973 second(s), 30 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表