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

 找回密码
 立即注册
12
返回列表 发新帖
楼主: guitengyue

[流程系列] 写了一个洗衣机洗完通知耗电和时间(修正bug 可以导入了)

[复制链接]

13

主题

220

帖子

644

积分

高级会员

Rank: 4

积分
644
金钱
422
HASS币
0
发表于 2021-9-13 14:04:48 | 显示全部楼层
guitengyue 发表于 2021-9-13 13:43
zhouhui920 发表于 2021-9-12 11:14
直接丢附件不会有这个问题这样可以了嘛

没用,就是这个代码弄的都不行,不知道论坛什么问题,要直接文件附件就没这个问题,虽然都是记事本代码
回复

使用道具 举报

1

主题

26

帖子

737

积分

高级会员

Rank: 4

积分
737
金钱
711
HASS币
0
发表于 2022-1-15 23:02:41 | 显示全部楼层
[ 本帖最后由 akarinwei 于 2022-1-15 23:05 编辑 ]\n\n[{"id":"4048e7e6.356be8","type":"tab","label":"洗衣机洗完通知","disabled":false,"info":""},{"id":"26d8b700.53d95a","type":"api-call-service","z":"4048e7e6.356be8","name":"通知所有手机","server":"5bb02c99.614f64","version":1,"debugenabled":false,"service_domain":"notify","service":"notify","entityId":"","data":"{\"title\":\"洗衣机\",\"message\":\"衣服洗完,本次消耗{{{flow.end}}}度,用时{{{flow.xhtime}}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1380,"y":560,"wires":[[]]},{"id":"82f5ba1.7686448","type":"server-state-changed","z":"4048e7e6.356be8","name":"洗衣机总功率<9","server":"5bb02c99.614f64","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.dc1_xiyiji_power","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"9","halt_if_type":"num","halt_if_compare":"lt","outputs":2,"output_only_on_state_change":true,"for":"60","forType":"num","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":180,"y":520,"wires":[["8bf8cc6c.2baeb"],[]]},{"id":"b60c1b32.41b608","type":"server-state-changed","z":"4048e7e6.356be8","name":"洗衣机总功玑�>30","server":"5bb02c99.614f64","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.dc1_xiyiji_power","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"30","halt_if_type":"num","halt_if_compare":"gt","outputs":2,"output_only_on_state_change":true,"for":"5","forType":"num","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":120,"y":380,"wires":[["e334d597.529908"],[]]},{"id":"8bf8cc6c.2baeb","type":"switch","z":"4048e7e6.356be8","name":"","property":"xyj","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":520,"wires":[["384b6575.78898a","45aa1499.9a302c"],[]]},{"id":"9eb8269.34ac4d8","type":"change","z":"4048e7e6.356be8","name":"设定xyj=1","rules":[{"t":"set","p":"xyj","pt":"flow","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":380,"wires":[[]]},{"id":"384b6575.78898a","type":"change","z":"4048e7e6.356be8","name":"设定xyj=0","rules":[{"t":"set","p":"xyj","pt":"flow","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":620,"wires":[[]]},{"id":"10e54243.7a95be","type":"api-call-service","z":"4048e7e6.356be8","name":"只通知我的手机","server":"5bb02c99.614f64","version":1,"debugenabled":false,"service_domain":"notify","service":"mobile_app_tengyuede_iphone","entityId":"","data":"{\"title\":\"洗衣机\",\"message\":\"衣服洗完,本次消耗{{{flow.end}}}度,用时{{{flow.xhtime}}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1400,"y":480,"wires":[[]]},{"id":"e334d597.529908","type":"switch","z":"4048e7e6.356be8","name":"","property":"xyj","propertyType":"flow","rules":[{"t":"neq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":310,"y":380,"wires":[["9eb8269.34ac4d8","a81653d6.39fd2","c25687cb.3a98f8"],[]],"info":"xyj=0的时候,且功率触发》30,记录当前电表读数"},{"id":"a1d3aea4.62ad9","type":"function","z":"4048e7e6.356be8","name":"计算能耗","func":"var start = flow.get('start',start);\nvar finish = flow.get('finish',finish);\nvar dianneng = finish - start;\nmsg.payload = dianneng.toFixed(2);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":800,"y":540,"wires":[["6282f71f.1b0a38"]]},{"id":"a81653d6.39fd2","type":"api-current-state","z":"4048e7e6.356be8","name":"记录开始洗电能","server":"5bb02c99.614f64","version":1,"outputs":2,"halt_if":"0","halt_if_type":"num","halt_if_compare":"is_not","override_topic":true,"entity_id":"sensor.dc1_xiyiji_total","state_type":"num","state_location":"start","override_payload":"flow","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":500,"y":440,"wires":[[],[]]},{"id":"45aa1499.9a302c","type":"api-current-state","z":"4048e7e6.356be8","name":"记录结束电能","server":"5bb02c99.614f64","version":1,"outputs":2,"halt_if":"0","halt_if_type":"num","halt_if_compare":"is_not","override_topic":true,"entity_id":"sensor.dc1_xiyiji_total","state_type":"num","state_location":"finish","override_payload":"flow","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":580,"y":520,"wires":[["a1d3aea4.62ad9","488104ff.80f39c"],[]]},{"id":"6282f71f.1b0a38","type":"change","z":"4048e7e6.356be8","name":"转移数据","rules":[{"t":"move","p":"payload","pt":"msg","to":"end","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":480,"wires":[["5cff32a1.b2cfcc"]]},{"id":"c25687cb.3a98f8","type":"function","z":"4048e7e6.356be8","name":"获取开始时间","func":"var date = new Date();\nmsg.payload = date;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":320,"wires":[["f5b322aa.d8512"]]},{"id":"f5b322aa.d8512","type":"change","z":"4048e7e6.356be8","name":"转移数据","rules":[{"t":"move","p":"payload","pt":"msg","to":"timestart","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":280,"wires":[[]]},{"id":"488104ff.80f39c","type":"function","z":"4048e7e6.356be8","name":"计算消耗时间","func":"var nowdate = new Date();\nvar timestart = flow.get('timestart',timestart);\nvar difftime = (nowdate - timestart)/1000;\nvar hours = parseInt(difftime/3600);    // 小时 60*60 总小时数-过去的小时数=现在的小时数 \nvar minutes = parseInt(difftime%3600/60); // 分钟 -(day*24) 以60秒丽�一敨�份 取余 剩下秒数 秒数/60 就是分钟数\nvar seconds = parseInt(difftime%60);  // 以60秒为一整份 取余 剩下秒数\nmsg.payload = hours+\"h\"+minutes+\"min\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":800,"y":600,"wires":[["44f9d7f4.526478"]]},{"id":"44f9d7f4.526478","type":"change","z":"4048e7e6.356be8","name":"转移数据","rules":[{"t":"move","p":"payload","pt":"msg","to":"xhtime","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":980,"y":640,"wires":[[]]},{"id":"5cff32a1.b2cfcc","type":"stoptimer","z":"4048e7e6.356be8","duration":"5","units":"Second","payloadtype":"num","payloadval":"0","name":"","x":1160,"y":480,"wires":[["26d8b700.53d95a"],[]]},{"id":"5bb02c99.614f64","type":"server","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]


按解析出错提示给双引号加了转义能导入了...但是我是nodered刚入门,想用小爱音箱来提醒是不是改最后的“只通知我的手机”部分就行了
回复

使用道具 举报

73

主题

1165

帖子

6641

积分

论坛元老

Rank: 8Rank: 8

积分
6641
金钱
5471
HASS币
30
发表于 2022-1-16 05:20:10 | 显示全部楼层
代码最好不要用复制,导出文件,这样大家导入就不会出现问题啦
回复

使用道具 举报

25

主题

284

帖子

1471

积分

金牌会员

Rank: 6Rank: 6

积分
1471
金钱
1187
HASS币
0
发表于 2022-1-16 11:13:54 | 显示全部楼层
安卓手机怎么也用不了notify,收不到消息
回复

使用道具 举报

66

主题

779

帖子

4407

积分

论坛元老

Rank: 8Rank: 8

积分
4407
金钱
3623
HASS币
20
 楼主| 发表于 2022-5-26 15:20:11 | 显示全部楼层
重新复制了下,应该是原来os有问题
现在应该可以导入了
回复

使用道具 举报

7

主题

106

帖子

754

积分

高级会员

Rank: 4

积分
754
金钱
648
HASS币
0
发表于 2023-5-28 21:57:06 | 显示全部楼层
guitengyue 发表于 2022-5-26 15:20
重新复制了下,应该是原来os有问题
现在应该可以导入了

还是不能导入啊。。。
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-22 09:43 , Processed in 0.050432 second(s), 26 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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