用户
 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

11

主题

15

帖子

5328

积分

论坛元老

Rank: 8Rank: 8

积分
5328
2019-9-16 18:05:27 lidicn 论坛元老 楼主 0137
本帖最后由 lidicn 于 2019-9-16 18:06 编辑
电热水壶和消毒碗柜都同时插在一个可即时更新功率的插座上.
如何来实现水壶烧完水, 消毒碗柜消毒完碗时TTS提醒呢?

前置需求

  1. 可查询即时功率的插座, 本例用的是米家智能插座带usb口的增强版
  2. 配置好InfluxDB数据库, 可参考妖神教程
  3. TTS

原理简述

  1. 当功率从较高状态下, 下降为1w, 可判断为 消毒或水壶完成了消毒或烧水
  2. 查询60秒前到现在,功率的最大值,  如果较高就是烧完水, 如果较低就是消毒完成

安装InfluxDB节点

TIM截图20190916175323.jpg

配置InfluxDB节点

TIM截图20190916175424.jpg

node-red 流

TIM截图20190916180020.jpg

[{"id":"74d482d0.8bc0fc","type":"ioBroker in","z":"8d3e5e26.c7e32","name":"米家恒温水壶插座功率","topic":"miio.0.devices.91908807.loadPower","payloadType":"object","onlyack":"","func":"all","gap":"","x":140,"y":2020,"wires":[["3530abf6.bdc574","da772e8d.34c1c"]]},{"id":"e8247e62.61a66","type":"debug","z":"8d3e5e26.c7e32","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":890,"y":1920,"wires":[]},{"id":"da772e8d.34c1c","type":"switch","z":"8d3e5e26.c7e32","name":"过滤非即时更新的消息","property":"timestamp","propertyType":"msg","rules":[{"t":"eq","v":"lastchange","vt":"msg"}],"checkall":"true","repair":false,"outputs":1,"x":420,"y":2020,"wires":[["aa19a930.eba7d8"]]},{"id":"aa19a930.eba7d8","type":"switch","z":"8d3e5e26.c7e32","name":"","property":"payload.val","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":630,"y":2020,"wires":[["e8247e62.61a66","2cce0a35.b7b266"]]},{"id":"65d01e2c.1772f","type":"function","z":"8d3e5e26.c7e32","name":"烧水输出TTS内容","func":"msg.payload = `米家恒温水壶烧水程序已完成`;\nreturn msg;","outputs":1,"noerr":0,"x":1690,"y":2000,"wires":[[]]},{"id":"3530abf6.bdc574","type":"debug","z":"8d3e5e26.c7e32","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":420,"y":2100,"wires":[]},{"id":"38cfaa7.d541056","type":"comment","z":"8d3e5e26.c7e32","name":"米家恒温水壶烧水提醒","info":"","x":140,"y":1960,"wires":[]},{"id":"2cce0a35.b7b266","type":"influxdb in","z":"8d3e5e26.c7e32","influxdb":"224365dd.1bf8da","name":"查询一小时内插座的最大功率","query":"SELECT max(*) FROM \"miio.0.devices.91908807.loadPower\" WHERE time > now() - 60s","rawOutput":false,"precision":"","retentionPolicy":"","x":860,"y":2020,"wires":[["2448c312.fcd91c","b3de142c.4d36e8"]]},{"id":"81960f5e.283ab","type":"debug","z":"8d3e5e26.c7e32","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1330,"y":2180,"wires":[]},{"id":"2448c312.fcd91c","type":"moment","z":"8d3e5e26.c7e32","name":"转换时间格式","topic":"","input":"payload[0].time","inputType":"msg","inTz":"Asia/Shanghai","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD HH:mm","locale":"C","output":"time","outputType":"msg","outTz":"Asia/Shanghai","x":1120,"y":2020,"wires":[["81960f5e.283ab","b3dbb248.e6817"]]},{"id":"b3de142c.4d36e8","type":"debug","z":"8d3e5e26.c7e32","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1070,"y":2180,"wires":[]},{"id":"b3dbb248.e6817","type":"switch","z":"8d3e5e26.c7e32","name":"功率最大值判断机器","property":"payload[0].max_value","propertyType":"msg","rules":[{"t":"gte","v":"800","vt":"num"},{"t":"lt","v":"800","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":1380,"y":2020,"wires":[["65d01e2c.1772f"],["5c68e6b9.7e18f8"]]},{"id":"5c68e6b9.7e18f8","type":"function","z":"8d3e5e26.c7e32","name":"消毒完成输出TTS内容","func":"msg.payload = `康宝消毒碗柜消毒程序已完成`;\nreturn msg;","outputs":1,"noerr":0,"x":1680,"y":2060,"wires":[[]]},{"id":"224365dd.1bf8da","type":"influxdb","z":"","hostname":"192.168.2.101","port":"8086","protocol":"http","database":"iobroker","name":"","usetls":false,"tls":""}]



使用道具 举报 回复
发新帖
您需要登录后才可以回帖 登录 | 立即注册