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

 找回密码
 立即注册
查看: 6155|回复: 15

[新奇玩法] 分享一个小米空气净化器的NR流

[复制链接]

9

主题

157

帖子

2188

积分

金牌会员

Rank: 6Rank: 6

积分
2188
金钱
2031
HASS币
10
发表于 2021-4-19 15:09:50 | 显示全部楼层 |阅读模式
本帖最后由 tangxingjie1991 于 2021-4-20 09:00 编辑

用ha自带的homekit接入空气净化器是个风扇,故改用NR接入hk,需要安装节点 node-red-contrib-homekit-bridged附件来了
[{"id":"2611100b.251df","type":"tab","label":"空气净化器","disabled":false,"info":""},{"id":"398e1722.d7d75","type":"homekit-service","z":"2611100b.251df","isParent":true,"hostType":"0","bridge":"8d00484b.f1d4c8","accessoryId":"","parentService":"","name":"空气净化器","serviceName":"AirPurifier","topic":"","filter":false,"manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","firmwareRev":"","hardwareRev":"","softwareRev":"","cameraConfigVideoProcessor":"","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":"","cameraConfigMaxWidth":"","cameraConfigMaxHeight":"","cameraConfigMaxFPS":"","cameraConfigMaxBitrate":"","cameraConfigVideoCodec":"","cameraConfigAudioCodec":"","cameraConfigAudio":false,"cameraConfigPacketSize":"","cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"","cameraConfigMapAudio":"","cameraConfigVideoFilter":"","cameraConfigAdditionalCommandLine":"","cameraConfigDebug":false,"cameraConfigInterfaceName":"","characteristicProperties":"{"TargetAirPurifierState":true,"LockPhysicalControls":true,"RotationSpeed":{"minValue":1,"maxValue":15,"minStep":1},"FilterLifeLevel":true,"CurrentRelativeHumidity":0,"PM2_5Density":1}","waitForSetupMsg":false,"outputs":2,"x":930,"y":700,"wires":[["aaeec4fb.92a798"],[]]},{"id":"aaeec4fb.92a798","type":"switch","z":"2611100b.251df","name":"判断","property":"payload","propertyType":"msg","rules":[{"t":"hask","v":"Active","vt":"str"},{"t":"hask","v":"TargetAirPurifierState","vt":"str"},{"t":"hask","v":"RotationSpeed","vt":"str"},{"t":"hask","v":"LockPhysicalControls","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":1130,"y":700,"wires":[["dfdf0b12.69a538"],["152e9a9.1029a65"],["2b1ec971.4c4226"],["32aec2a0.41c5de"]]},{"id":"dfdf0b12.69a538","type":"switch","z":"2611100b.251df","name":"开关","property":"payload.Active","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":1410,"y":540,"wires":[["aaa8096a.b8be58"],["80c58fff.bbbab"]]},{"id":"152e9a9.1029a65","type":"switch","z":"2611100b.251df","name":"模式","property":"payload.TargetAirPurifierState","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1410,"y":620,"wires":[["4b1c06c7.debec8"],["dbd8855d.1122b8"]]},{"id":"96f581be.61734","type":"api-call-service","z":"2611100b.251df","name":"","server":"9f12f038.c14df","version":1,"debugenabled":false,"service_domain":"xiaomi_miio_airpurifier","service":"fan_set_favorite_level","entityId":"fan.xiaomi_air_purifier_2","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1750,"y":760,"wires":[[]]},{"id":"2b1ec971.4c4226","type":"function","z":"2611100b.251df","name":"设置速度","func":"msg.payload.data={"level":`${msg.payload.RotationSpeed}`-1}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1420,"y":760,"wires":[["96f581be.61734"]]},{"id":"aaa8096a.b8be58","type":"api-call-service","z":"2611100b.251df","name":"","server":"9f12f038.c14df","version":1,"debugenabled":false,"service_domain":"fan","service":"turn_off","entityId":"fan.xiaomi_air_purifier_2","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1640,"y":500,"wires":[[]]},{"id":"80c58fff.bbbab","type":"api-call-service","z":"2611100b.251df","name":"","server":"9f12f038.c14df","version":1,"debugenabled":false,"service_domain":"fan","service":"turn_on","entityId":"fan.xiaomi_air_purifier_2","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1640,"y":560,"wires":[[]]},{"id":"4b1c06c7.debec8","type":"api-call-service","z":"2611100b.251df","name":"","server":"9f12f038.c14df","version":1,"debugenabled":false,"service_domain":"fan","service":"set_preset_mode","entityId":"fan.xiaomi_air_purifier_2","data":"{"preset_mode": "Auto"}","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1670,"y":620,"wires":[[]]},{"id":"dbd8855d.1122b8","type":"api-call-service","z":"2611100b.251df","name":"","server":"9f12f038.c14df","version":1,"debugenabled":false,"service_domain":"fan","service":"set_preset_mode","entityId":"fan.xiaomi_air_purifier_2","data":"{"preset_mode": "Favorite"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1670,"y":680,"wires":[[]]},{"id":"32aec2a0.41c5de","type":"switch","z":"2611100b.251df","name":"儿童锁","property":"payload.LockPhysicalControls","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":1410,"y":860,"wires":[["df21b274.9ca45"],["c0cd00ae.08d0a"]]},{"id":"c0cd00ae.08d0a","type":"api-call-service","z":"2611100b.251df","name":"","server":"9f12f038.c14df","version":1,"debugenabled":false,"service_domain":"xiaomi_miio_airpurifier","service":"fan_set_child_lock_on","entityId":"fan.xiaomi_air_purifier_2","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1750,"y":900,"wires":[[]]},{"id":"df21b274.9ca45","type":"api-call-service","z":"2611100b.251df","name":"","server":"9f12f038.c14df","version":1,"debugenabled":false,"service_domain":"xiaomi_miio_airpurifier","service":"fan_set_child_lock_off","entityId":"fan.xiaomi_air_purifier_2","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1750,"y":840,"wires":[[]]},{"id":"3357ad0c.dc80b2","type":"poll-state","z":"2611100b.251df","name":"","server":"9f12f038.c14df","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"60","updateIntervalUnits":"seconds","outputinitially":false,"outputonchanged":false,"entity_id":"fan.xiaomi_air_purifier_2","state_type":"str","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":160,"y":680,"wires":[["cd556164.f53ad","58e67d20.7fb854","e4fe35c4.5b2058","8601d2ff.71f59"]]},{"id":"cd556164.f53ad","type":"switch","z":"2611100b.251df","name":"模式","property":"data.attributes.preset_mode","propertyType":"msg","rules":[{"t":"eq","v":"Auto","vt":"str"},{"t":"neq","v":"Auto","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":500,"wires":[["ba360278.c7fa"],["6d19cd3.c507934"]]},{"id":"ba360278.c7fa","type":"change","z":"2611100b.251df","name":"Manual Mode","rules":[{"t":"set","p":"payload","pt":"msg","to":"{"TargetAirPurifierState":1}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":500,"wires":[["398e1722.d7d75"]]},{"id":"6d19cd3.c507934","type":"change","z":"2611100b.251df","name":"Auto mode","rules":[{"t":"set","p":"payload","pt":"msg","to":"{"TargetAirPurifierState":0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":540,"wires":[["398e1722.d7d75"]]},{"id":"6c28bbea.5d9b94","type":"debug","z":"2611100b.251df","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"data","targetType":"msg","statusVal":"data","statusType":"auto","x":970,"y":400,"wires":[]},{"id":"58e67d20.7fb854","type":"switch","z":"2611100b.251df","name":"童锁","property":"data.attributes.child_lock","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":680,"wires":[["aa39b0b7.8d46f"],["812786cc.36fee8"]]},{"id":"aa39b0b7.8d46f","type":"change","z":"2611100b.251df","name":"Child lock on","rules":[{"t":"set","p":"payload","pt":"msg","to":"{"LockPhysicalControls":1}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":680,"wires":[["398e1722.d7d75"]]},{"id":"812786cc.36fee8","type":"change","z":"2611100b.251df","name":"Child lock off","rules":[{"t":"set","p":"payload","pt":"msg","to":"{"LockPhysicalControls":0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":720,"wires":[["398e1722.d7d75"]]},{"id":"e4fe35c4.5b2058","type":"switch","z":"2611100b.251df","name":"状态","property":"data.state","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":840,"wires":[["94cdb5f2.adf4a8"],["f49b6684.cfbc88"]]},{"id":"94cdb5f2.adf4a8","type":"change","z":"2611100b.251df","name":"state: on","rules":[{"t":"set","p":"payload","pt":"msg","to":"{"Active":true,"CurrentAirPurifierState":2}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":840,"wires":[["398e1722.d7d75"]]},{"id":"f49b6684.cfbc88","type":"change","z":"2611100b.251df","name":"state: off","rules":[{"t":"set","p":"payload","pt":"msg","to":"{"Active":false,"CurrentAirPurifierState":0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":880,"wires":[["398e1722.d7d75"]]},{"id":"8601d2ff.71f59","type":"function","z":"2611100b.251df","name":"设置属性","func":"msg.payload={"CurrentRelativeHumidity":`${msg.data.attributes.humidity}`,"FilterLifeLevel":`${msg.data.attributes.filter_life_remaining}`,"PM2_5Density":`${msg.data.attributes.aqi}`,"RotationSpeed":`${msg.data.attributes.favorite_level}`}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":620,"y":1000,"wires":[["398e1722.d7d75"]]},{"id":"1a921a50.6c9046","type":"debug","z":"2611100b.251df","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1080,"y":980,"wires":[]},{"id":"fb699f9c.128a8","type":"server-state-changed","z":"2611100b.251df","name":"","server":"9f12f038.c14df","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"fan.xiaomi_air_purifier_2","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":180,"y":820,"wires":[["9f5c144e.3e64f8","191f6ac4.0c8975","a75a0e42.8b0dc","1942f54b.fcf14b"]]},{"id":"9f5c144e.3e64f8","type":"switch","z":"2611100b.251df","name":"模式","property":"data.new_state.attributes.preset_mode","propertyType":"msg","rules":[{"t":"eq","v":"Auto","vt":"str"},{"t":"neq","v":"Auto","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":540,"wires":[["ba360278.c7fa"],["6d19cd3.c507934"]]},{"id":"191f6ac4.0c8975","type":"switch","z":"2611100b.251df","name":"童锁","property":"data.new_state.attributes.child_lock","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":720,"wires":[["aa39b0b7.8d46f"],["812786cc.36fee8"]]},{"id":"a75a0e42.8b0dc","type":"switch","z":"2611100b.251df","name":"状态","property":"data.new_state.state","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":880,"wires":[["94cdb5f2.adf4a8"],["f49b6684.cfbc88"]]},{"id":"1942f54b.fcf14b","type":"function","z":"2611100b.251df","name":"设置属性","func":"msg.payload={"CurrentRelativeHumidity":`${msg.data.new_state.attributes.humidity}`,"FilterLifeLevel":`${msg.data.new_state.attributes.filter_life_remaining}`,"PM2_5Density":`${msg.data.new_state.attributes.aqi}`,"RotationSpeed":`${msg.data.new_state.attributes.favorite_level}`}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":620,"y":1060,"wires":[["398e1722.d7d75"]]},{"id":"8d00484b.f1d4c8","type":"homekit-bridge","bridgeName":"nodered桥","pinCode":"368-05-913","port":"","advertiser":"bonjour-hap","allowInsecureRequest":false,"manufacturer":"NRCHKB","model":"1.3.1","serialNo":"Default Serial Number","firmwareRev":"1.3.1","hardwareRev":"1.3.1","softwareRev":"1.3.1","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true,"allowMessagePassthrough":true},{"id":"9f12f038.c14df","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]



微信图片_20210419150614.jpg

flows (1).zip

2.86 KB, 下载次数: 254

评分

参与人数 3金钱 +44 收起 理由
735473216 + 8 墙都不扶,就服楼主!
eric + 16 感谢楼主分享!
+ 20 感谢楼主分享!

查看全部评分

回复

使用道具 举报

4

主题

342

帖子

2694

积分

金牌会员

Rank: 6Rank: 6

积分
2694
金钱
2352
HASS币
0
发表于 2021-4-19 15:46:59 | 显示全部楼层
导入提示错误:SyntaxError: Unexpected token T in JSON at position 1069
回复

使用道具 举报

40

主题

3056

帖子

1万

积分

超级版主

Nero

Rank: 8Rank: 8

积分
11149
金钱
8042
HASS币
182
发表于 2021-4-19 16:06:14 | 显示全部楼层
建议楼主打包zip 文件上传附件
Nero
回复

使用道具 举报

73

主题

1165

帖子

6641

积分

论坛元老

Rank: 8Rank: 8

积分
6641
金钱
5471
HASS币
30
发表于 2021-4-19 18:50:53 | 显示全部楼层
无法导入,请将NR流打包上传附件
回复

使用道具 举报

9

主题

157

帖子

2188

积分

金牌会员

Rank: 6Rank: 6

积分
2188
金钱
2031
HASS币
10
 楼主| 发表于 2021-4-20 09:01:13 | 显示全部楼层
neroxps 发表于 2021-4-19 16:06
建议楼主打包zip 文件上传附件

好嘞         
回复

使用道具 举报

2

主题

60

帖子

448

积分

中级会员

Rank: 3Rank: 3

积分
448
金钱
388
HASS币
0
发表于 2021-4-26 11:33:44 | 显示全部楼层
不能用
回复

使用道具 举报

7

主题

227

帖子

2258

积分

论坛积极会员

积分
2258
金钱
2031
HASS币
0
发表于 2021-4-26 12:59:49 | 显示全部楼层
感谢分享
回复

使用道具 举报

12

主题

176

帖子

2068

积分

金牌会员

Rank: 6Rank: 6

积分
2068
金钱
1892
HASS币
0
发表于 2022-1-11 15:09:59 | 显示全部楼层
本帖最后由 735473216 于 2022-1-11 15:28 编辑

好贴,为什么当初我没有仔细搜索一下

另外问下楼主用什么集成接入的空净,我用xiaomi miio接入的,favoritelevel childlock这种都不在fan的attributes中了,变成了独立的实体
回复

使用道具 举报

9

主题

157

帖子

2188

积分

金牌会员

Rank: 6Rank: 6

积分
2188
金钱
2031
HASS币
10
 楼主| 发表于 2022-1-11 16:39:42 | 显示全部楼层
735473216 发表于 2022-1-11 15:09
好贴,为什么当初我没有仔细搜索一下

另外问下楼主用什么集成接入的空净,我用xiaomi miio接入的,favo ...

我是用MIoT这个集成接入的
回复

使用道具 举报

12

主题

176

帖子

2068

积分

金牌会员

Rank: 6Rank: 6

积分
2068
金钱
1892
HASS币
0
发表于 2022-1-11 17:32:42 | 显示全部楼层
tangxingjie1991 发表于 2022-1-11 16:39
我是用MIoT这个集成接入的

好的,我根据我的调整下

poll和change两个输入,poll是为了nr重启的时候可以更新状态吗?
我试了一下poll的间隔设置为1分钟,在nr启动后1分钟才会有第一次触发输入,这个还有什么优化空间吗
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-24 20:35 , Processed in 0.386656 second(s), 35 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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