Monitoring z-wave devices with node-red

Tags: #<Tag:0x00007f7398e82e08>

I always wanted to monitor z-wave devices in HA, but could not find an easy way to do it. This week I started using nodered and found a way to scan for potentially problematic devices and output it to a webpage/iframe in lovelace based off a number of rules.

I don’t know if there are more accurate or simpler metrics to identify devices that need attention so please feel free to chime in. The joins use a 1 second wait rather than waiting for a complete signal and the output isn’t pretty.

Please help me improve this!

[{"id":"6516b20e.76693c","type":"comment","z":"2becb7c1.508c48","name":"Get Failed Entities","info":"","x":170,"y":260,"wires":[]},{"id":"6533dda0.109ae4","type":"switch","z":"2becb7c1.508c48","name":"retries > 0","property":"payload.attributes.retries","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":660,"y":260,"wires":[["8d0ff8fc.8e15a8"]]},{"id":"45bbddfc.9e98f4","type":"ha-get-entities","z":"2becb7c1.508c48","server":"b07239dc.8d8338","name":"","rules":[{"property":"entity_id","logic":"starts_with","value":"zwave.","valueType":"str"}],"output_type":"array","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":270,"y":460,"wires":[["f7e8176e.a99c68"]]},{"id":"f7e8176e.a99c68","type":"split","z":"2becb7c1.508c48","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":430,"y":460,"wires":[["6533dda0.109ae4","13259dc3.bf96b2","a6d22b5a.650f38","23401051.3bcbc","f7435057.26271","9991c254.9a30d"]]},{"id":"13259dc3.bf96b2","type":"switch","z":"2becb7c1.508c48","name":"is_failed is true","property":"payload.attributes.is_failed","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":680,"y":320,"wires":[["bb4a73c.e02b59"]]},{"id":"a6d22b5a.650f38","type":"switch","z":"2becb7c1.508c48","name":"is_ready is false","property":"payload.attributes.is_ready","propertyType":"msg","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":680,"y":380,"wires":[["d6701bac.224d08"]]},{"id":"23401051.3bcbc","type":"switch","z":"2becb7c1.508c48","name":"query_stage is not null","property":"payload.attributes.query_stage","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":700,"y":440,"wires":[["47a405d2.5dd8ac"]]},{"id":"f7435057.26271","type":"switch","z":"2becb7c1.508c48","name":"state is not ready","property":"payload.state","propertyType":"msg","rules":[{"t":"neq","v":"ready","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":690,"y":560,"wires":[["36ebc915.dd40d6"]]},{"id":"8d0ff8fc.8e15a8","type":"join","z":"2becb7c1.508c48","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":970,"y":260,"wires":[["58de67dc.b62ed8"]]},{"id":"47a405d2.5dd8ac","type":"switch","z":"2becb7c1.508c48","name":"query_stage is not Complete","property":"payload.attributes.query_stage","propertyType":"msg","rules":[{"t":"neq","v":"Complete","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":720,"y":500,"wires":[["5bdfe90b.d31cf8"]]},{"id":"58de67dc.b62ed8","type":"change","z":"2becb7c1.508c48","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"retries","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":260,"wires":[["9afa53cd.9af68"]]},{"id":"2d089924.de41a6","type":"change","z":"2becb7c1.508c48","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"is_failed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":320,"wires":[["9afa53cd.9af68"]]},{"id":"55d8be24.d5461","type":"change","z":"2becb7c1.508c48","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"is_ready","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":380,"wires":[["9afa53cd.9af68"]]},{"id":"a89eb9a0.f4a6f8","type":"change","z":"2becb7c1.508c48","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"query_stage","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":500,"wires":[["9afa53cd.9af68"]]},{"id":"8f9c40e6.24d79","type":"change","z":"2becb7c1.508c48","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"state","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":620,"wires":[["9afa53cd.9af68"]]},{"id":"9afa53cd.9af68","type":"join","z":"2becb7c1.508c48","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1390,"y":460,"wires":[["d9b82500.c571a8"]]},{"id":"bb4a73c.e02b59","type":"join","z":"2becb7c1.508c48","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":970,"y":320,"wires":[["2d089924.de41a6"]]},{"id":"d6701bac.224d08","type":"join","z":"2becb7c1.508c48","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":970,"y":380,"wires":[["55d8be24.d5461"]]},{"id":"5bdfe90b.d31cf8","type":"join","z":"2becb7c1.508c48","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":970,"y":500,"wires":[["a89eb9a0.f4a6f8"]]},{"id":"600ef1db.e27c8","type":"join","z":"2becb7c1.508c48","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":970,"y":620,"wires":[["8f9c40e6.24d79"]]},{"id":"9991c254.9a30d","type":"switch","z":"2becb7c1.508c48","name":"battery_level < 100","property":"payload.attributes.battery_level","propertyType":"msg","rules":[{"t":"lt","v":"100","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":690,"y":680,"wires":[["27e830f0.7a42d"]]},{"id":"c9a8cf13.e9461","type":"change","z":"2becb7c1.508c48","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"battery_level","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":680,"wires":[["9afa53cd.9af68"]]},{"id":"27e830f0.7a42d","type":"join","z":"2becb7c1.508c48","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":970,"y":680,"wires":[["c9a8cf13.e9461"]]},{"id":"36ebc915.dd40d6","type":"switch","z":"2becb7c1.508c48","name":"state is not sleeping","property":"payload.state","propertyType":"msg","rules":[{"t":"neq","v":"sleeping","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":700,"y":620,"wires":[["600ef1db.e27c8"]]},{"id":"d9b82500.c571a8","type":"template","z":"2becb7c1.508c48","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<h3>is_failed</h3>\n<ul>\n{{#payload.is_failed}}\n<li>{{entity_id}} = {{attributes.is_failed}}</li>\n{{/payload.is_failed}}\n</ul>\n\n<h3>is_ready</h3>\n<ul>\n{{#payload.is_ready}}\n<li>{{entity_id}} = {{attributes.is_ready}}</li>\n{{/payload.is_ready}}\n</ul>\n\n<h3>query_stage</h3>\n<ul>\n{{#payload.query_stage}}\n<li>{{entity_id}} = {{attributes.query_stage}}</li>\n{{/payload.query_stage}}\n</ul>\n\n<h3>state</h3>\n<ul>\n{{#payload.state}}\n<li>{{entity_id}} = {{state}}</li>\n{{/payload.state}}\n</ul>\n\n<h3>battery_level</h3>\n<ul>\n{{#payload.battery_level}}\n<li>{{entity_id}} = {{attributes.battery_level}}</li>\n{{/payload.battery_level}}\n</ul>\n\n<h3>retries</h3>\n<ul>\n{{#payload.retries}}\n<li>{{entity_id}} = {{attributes.retries}}</li>\n{{/payload.retries}}\n</ul>","output":"str","x":1540,"y":460,"wires":[["1d0d1d4c.630c23"]]},{"id":"ad40ca97.9f2398","type":"http in","z":"2becb7c1.508c48","name":"","url":"/zwave_failed_devices","method":"get","upload":false,"swaggerDoc":"","x":220,"y":400,"wires":[["45bbddfc.9e98f4"]]},{"id":"1d0d1d4c.630c23","type":"http response","z":"2becb7c1.508c48","name":"","statusCode":"","headers":{},"x":1670,"y":460,"wires":[]},{"id":"b07239dc.8d8338","type":"server","z":"","name":"Home Assistant","addon":true}]

I’ve been also trying to figure out what is a best practice to monitor zwave devices as well! I’m interested to see the communities response.