|
Bogdan Timofte
authored
2 weeks ago
|
1
|
<script type="text/x-red" data-template-name="z2m-snzb-05p-homebus">
|
|
|
2
|
<div class="form-row">
|
|
|
3
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
|
4
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
|
5
|
</div>
|
|
|
6
|
<div class="form-row">
|
|
|
7
|
<label for="node-input-site"><i class="fa fa-globe"></i> Site</label>
|
|
|
8
|
<input type="text" id="node-input-site" placeholder="unknown">
|
|
|
9
|
</div>
|
|
|
10
|
<div class="form-row">
|
|
|
11
|
<label for="node-input-batteryLowThreshold">Battery low threshold (%)</label>
|
|
|
12
|
<input type="number" id="node-input-batteryLowThreshold" min="0" max="100" placeholder="20">
|
|
|
13
|
</div>
|
|
|
14
|
</script>
|
|
|
15
|
|
|
|
16
|
<script type="text/x-red" data-help-name="z2m-snzb-05p-homebus">
|
|
|
17
|
<p>
|
|
|
18
|
Translates Zigbee2MQTT messages for SONOFF <code>SNZB-05P</code> water leak sensors into canonical HomeBus topics.
|
|
|
19
|
</p>
|
|
|
20
|
<p>
|
|
|
21
|
Canonical topic shape:
|
|
|
22
|
<code><site>/home/<location>/<capability>/<device_id>/<stream></code>
|
|
|
23
|
</p>
|
|
|
24
|
<p>
|
|
|
25
|
Example outputs:
|
|
|
26
|
<code>vad/home/bathroom/water_leak/sink-sensor/value</code>,
|
|
|
27
|
<code>vad/home/bathroom/battery/sink-sensor/last</code>,
|
|
|
28
|
<code>vad/home/bathroom/water_leak/sink-sensor/meta</code>
|
|
|
29
|
</p>
|
|
|
30
|
<h3>Input</h3>
|
|
|
31
|
<p>
|
|
|
32
|
Expected Zigbee2MQTT telemetry topic:
|
|
|
33
|
<code>zigbee2mqtt/SNZB-05P/<site>/<location>/<device_id></code> with a JSON payload.
|
|
|
34
|
</p>
|
|
|
35
|
<p>
|
|
|
36
|
Availability topic is also supported:
|
|
|
37
|
<code>zigbee2mqtt/SNZB-05P/<site>/<location>/<device_id>/availability</code> with payload <code>online</code> or <code>offline</code>.
|
|
|
38
|
</p>
|
|
|
39
|
<p>
|
|
|
40
|
Typical subscription for this adapter:
|
|
|
41
|
<code>zigbee2mqtt/SNZB-05P/#</code>
|
|
|
42
|
</p>
|
|
|
43
|
<p>
|
|
|
44
|
Output 2 controls a dynamic <code>mqtt in</code> node on the raw Zigbee2MQTT broker. On startup, the adapter emits
|
|
|
45
|
<code>{ action: "subscribe", topic: "zigbee2mqtt/SNZB-05P/#" }</code>.
|
|
|
46
|
</p>
|
|
|
47
|
<p>
|
|
|
48
|
This node is intended to fan out traffic for multiple <code>SNZB-05P</code> devices, not to be instantiated per device.
|
|
|
49
|
</p>
|
|
|
50
|
<p>
|
|
|
51
|
The node status shows adapter statistics such as detected devices, processed inputs, translated publications,
|
|
|
52
|
operational messages, and errors. Invalid topics, invalid messages, invalid payloads, and unmapped payloads are counted separately in the status text.
|
|
|
53
|
</p>
|
|
|
54
|
<p>
|
|
|
55
|
Used fields:
|
|
|
56
|
<code>water_leak</code>, <code>battery</code>, <code>battery_low</code>, <code>availability</code>, <code>online</code>.
|
|
|
57
|
Optional tamper-like fields are also supported when present:
|
|
|
58
|
<code>tamper</code>, <code>tampered</code>, <code>tamper_alarm</code>, <code>alarm_tamper</code>.
|
|
|
59
|
</p>
|
|
|
60
|
<h3>Output</h3>
|
|
|
61
|
<ol>
|
|
|
62
|
<li>MQTT-ready publish messages, emitted as an array of messages on the semantic/output path.</li>
|
|
|
63
|
<li><code>mqtt in</code> control messages for the raw Zigbee2MQTT subscription.</li>
|
|
|
64
|
</ol>
|
|
|
65
|
<p>
|
|
|
66
|
Semantic bus messages are published in minimal form only:
|
|
|
67
|
<code>msg.topic</code>, <code>msg.payload</code>, <code>msg.qos</code>, and <code>msg.retain</code>.
|
|
|
68
|
Adapter internals such as vendor payload snapshots are not forwarded on the HomeBus output.
|
|
|
69
|
</p>
|
|
|
70
|
<p>
|
|
|
71
|
Live telemetry is unified on <code>value</code>. The adapter publishes lightweight hot-path <code>value</code> updates and deduplicates them on change.
|
|
|
72
|
</p>
|
|
|
73
|
<p>
|
|
|
74
|
Retained <code>last</code> carries the timestamped latest known sample for bootstrap and freshness evaluation.
|
|
|
75
|
</p>
|
|
|
76
|
<p>
|
|
|
77
|
The <code>last</code> payload uses a small JSON envelope with <code>value</code> and <code>observed_at</code>. When the source does not provide a timestamp, the adapter uses ingestion time and marks <code>quality=estimated</code>.
|
|
|
78
|
</p>
|
|
|
79
|
<p>
|
|
|
80
|
The node publishes retained <code>meta</code> and <code>availability</code> topics plus live
|
|
|
81
|
<code>value</code> topics for the capabilities supported by this sensor, together with retained <code>last</code> for the latest timestamped sample.
|
|
|
82
|
</p>
|
|
|
83
|
<p>
|
|
|
84
|
Operational topics are emitted on the same output under:
|
|
|
85
|
<code><site>/sys/adapter/z2m-snzb-05p/{availability,stats,error,dlq}</code>.
|
|
|
86
|
</p>
|
|
|
87
|
<p>
|
|
|
88
|
The adapter identifier is fixed to <code>z2m-snzb-05p</code>. Device identity and <code>source_ref</code> are derived per message from the inbound topic or payload.
|
|
|
89
|
</p>
|
|
|
90
|
<p>
|
|
|
91
|
Mapping:
|
|
|
92
|
<code>water_leak -> water_leak/value</code>,
|
|
|
93
|
<code>battery -> battery/value</code>,
|
|
|
94
|
<code>battery_low -> battery_low/value</code>,
|
|
|
95
|
<code>tamper -> tamper/value</code> when available.
|
|
|
96
|
</p>
|
|
|
97
|
<p>
|
|
|
98
|
Identity is resolved with priority:
|
|
|
99
|
incoming topic, then message/payload fields, then fallback defaults
|
|
|
100
|
<code>unknown/unknown/snzb-05p</code>.
|
|
|
101
|
</p>
|
|
|
102
|
<p>
|
|
|
103
|
With the recommended topic structure, <code>site</code>, <code>location</code>, <code>device_id</code>,
|
|
|
104
|
and usually <code>source_ref</code> are inferred directly from the Zigbee2MQTT topic path.
|
|
|
105
|
</p>
|
|
|
106
|
<p>
|
|
|
107
|
If this node is created from an older flow JSON, legacy fields
|
|
|
108
|
<code>mqttBus</code>, <code>mqttRoom</code>, and <code>mqttSensor</code> are still accepted as fallbacks.
|
|
|
109
|
</p>
|
|
|
110
|
<p>
|
|
|
111
|
Malformed or unmappable inputs are routed to adapter operational topics instead of being embedded into semantic bus payloads.
|
|
|
112
|
</p>
|
|
|
113
|
<p>
|
|
|
114
|
Input validation is strict for the source topic. Non-conforming topics or payloads are also logged with <code>node.warn</code>/<code>node.error</code> in Node-RED so they are visible in flow messages in addition to <code>sys/adapter/z2m-snzb-05p/{error,dlq}</code>.
|
|
|
115
|
</p>
|
|
|
116
|
</script>
|
|
|
117
|
|
|
|
118
|
<script>
|
|
|
119
|
RED.nodes.registerType("z2m-snzb-05p-homebus", {
|
|
|
120
|
category: "myNodes",
|
|
|
121
|
color: "#d9ecfb",
|
|
|
122
|
defaults: {
|
|
|
123
|
name: { value: "" },
|
|
|
124
|
site: { value: "unknown" },
|
|
|
125
|
batteryLowThreshold: { value: 20, validate: RED.validators.number() },
|
|
|
126
|
mqttSite: { value: "" },
|
|
|
127
|
mqttBus: { value: "" },
|
|
|
128
|
mqttRoom: { value: "" },
|
|
|
129
|
mqttSensor: { value: "" }
|
|
|
130
|
},
|
|
|
131
|
inputs: 1,
|
|
|
132
|
outputs: 2,
|
|
|
133
|
icon: "font-awesome/fa-sitemap",
|
|
|
134
|
label: function() {
|
|
|
135
|
return this.name || "z2m-snzb-05p-homebus";
|
|
|
136
|
},
|
|
|
137
|
paletteLabel: "snzb-05p homebus"
|
|
|
138
|
});
|
|
|
139
|
</script>
|