|
Bogdan Timofte
authored
2 weeks ago
|
1
|
<script type="text/x-red" data-template-name="z2m-zg-204zv-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-batteryLowThreshold">Battery low threshold (%)</label>
|
|
|
8
|
<input type="number" id="node-input-batteryLowThreshold" min="0" max="100" placeholder="20">
|
|
|
9
|
</div>
|
|
|
10
|
<div class="form-row">
|
|
|
11
|
<label for="node-input-batteryType">Battery type</label>
|
|
|
12
|
<select id="node-input-batteryType">
|
|
|
13
|
<option value="alkaline">Alkaline</option>
|
|
|
14
|
<option value="nimh">Rechargeable NiMH</option>
|
|
|
15
|
</select>
|
|
|
16
|
</div>
|
|
|
17
|
</script>
|
|
|
18
|
|
|
|
19
|
<script type="text/x-red" data-help-name="z2m-zg-204zv-homebus">
|
|
|
20
|
<p>
|
|
|
21
|
Translates Zigbee2MQTT messages for HOBEIAN <code>ZG-204ZV</code> into canonical HomeBus topics.
|
|
|
22
|
</p>
|
|
|
23
|
<p>
|
|
|
24
|
Canonical topic shape:
|
|
|
25
|
<code><site>/home/<location>/<capability>/<device_id>/<stream></code>
|
|
|
26
|
</p>
|
|
|
27
|
<p>
|
|
|
28
|
Example outputs:
|
|
|
29
|
<code>vad/home/living-room/motion/radar-south/value</code>,
|
|
|
30
|
<code>vad/home/living-room/temperature/radar-south/value</code>,
|
|
|
31
|
<code>vad/home/living-room/temperature/radar-south/last</code>,
|
|
|
32
|
<code>vad/home/living-room/motion/radar-south/meta</code>
|
|
|
33
|
</p>
|
|
|
34
|
<h3>Input</h3>
|
|
|
35
|
<p>
|
|
|
36
|
Expected Zigbee2MQTT telemetry topic:
|
|
|
37
|
<code>zigbee2mqtt/ZG-204ZV/<site>/<location>/<device_id></code> with a JSON payload.
|
|
|
38
|
</p>
|
|
|
39
|
<p>
|
|
|
40
|
Availability topic is also supported:
|
|
|
41
|
<code>zigbee2mqtt/ZG-204ZV/<site>/<location>/<device_id>/availability</code> with payload <code>online</code> or <code>offline</code>.
|
|
|
42
|
</p>
|
|
|
43
|
<p>
|
|
|
44
|
Typical subscription for this adapter:
|
|
|
45
|
<code>zigbee2mqtt/ZG-204ZV/#</code>
|
|
|
46
|
</p>
|
|
|
47
|
<p>
|
|
|
48
|
Output 2 controls a dynamic <code>mqtt in</code> node on the raw Zigbee2MQTT broker. On startup, the adapter emits
|
|
|
49
|
<code>{ action: "subscribe", topic: "zigbee2mqtt/ZG-204ZV/#" }</code>.
|
|
|
50
|
</p>
|
|
|
51
|
<p>
|
|
|
52
|
This node is intended to fan out traffic for multiple <code>ZG-204ZV</code> devices, not to be instantiated per device.
|
|
|
53
|
</p>
|
|
|
54
|
<p>
|
|
|
55
|
The node status shows adapter statistics such as detected devices, processed inputs, translated publications,
|
|
|
56
|
operational messages, and errors. Invalid topics, invalid messages, invalid payloads, and unmapped payloads are counted separately in the status text.
|
|
|
57
|
</p>
|
|
|
58
|
<p>
|
|
|
59
|
Used fields: <code>presence</code>, <code>temperature</code>, <code>humidity</code>,
|
|
|
60
|
<code>fading_time</code>, <code>illuminance</code>, <code>battery</code>, <code>battery_low</code>,
|
|
|
61
|
<code>tamper</code>, <code>availability</code>, <code>online</code>.
|
|
|
62
|
</p>
|
|
|
63
|
<p>
|
|
|
64
|
Battery translation can be configured for the installed cells. Default is <code>Alkaline</code>.
|
|
|
65
|
When <code>Rechargeable NiMH</code> is selected, the adapter applies a curve-based remap to the incoming
|
|
|
66
|
Zigbee battery percentage before publishing <code>battery</code> and deriving <code>battery_low</code>.
|
|
|
67
|
</p>
|
|
|
68
|
<p>
|
|
|
69
|
The NiMH remap approximates an alkaline percentage to cell voltage and then projects that voltage onto a flatter
|
|
|
70
|
NiMH discharge curve. If the device firmware starts reporting a better native percentage later, switch the adapter back to
|
|
|
71
|
<code>Alkaline</code> to disable the translation.
|
|
|
72
|
</p>
|
|
|
73
|
<h3>Output</h3>
|
|
|
74
|
<ol>
|
|
|
75
|
<li>MQTT-ready publish messages, emitted as an array of messages on the semantic/output path.</li>
|
|
|
76
|
<li><code>mqtt in</code> control messages for the raw Zigbee2MQTT subscription.</li>
|
|
|
77
|
</ol>
|
|
|
78
|
<p>
|
|
|
79
|
Semantic bus messages are published in minimal form only:
|
|
|
80
|
<code>msg.topic</code>, <code>msg.payload</code>, <code>msg.qos</code>, and <code>msg.retain</code>.
|
|
|
81
|
Adapter internals such as vendor payload snapshots are not forwarded on the HomeBus output.
|
|
|
82
|
</p>
|
|
|
83
|
<p>
|
|
|
84
|
Live telemetry is unified on <code>value</code>. The adapter publishes lightweight hot-path <code>value</code> updates and deduplicates them on change.
|
|
|
85
|
</p>
|
|
|
86
|
<p>
|
|
|
87
|
Retained <code>last</code> carries the timestamped latest known sample for bootstrap and freshness evaluation.
|
|
|
88
|
</p>
|
|
|
89
|
<p>
|
|
|
90
|
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>.
|
|
|
91
|
</p>
|
|
|
92
|
<p>
|
|
|
93
|
The node publishes retained <code>meta</code> and <code>availability</code> topics plus live
|
|
|
94
|
<code>value</code> topics for the capabilities supported by this sensor, together with retained <code>last</code> for the latest timestamped sample.
|
|
|
95
|
</p>
|
|
|
96
|
<p>
|
|
|
97
|
Operational topics are emitted on the same output under:
|
|
|
98
|
<code><site>/sys/adapter/z2m-zg-204zv/{availability,stats,error,dlq}</code>.
|
|
|
99
|
</p>
|
|
|
100
|
<p>
|
|
|
101
|
The adapter identifier is fixed to <code>z2m-zg-204zv</code>. Device identity and <code>source_ref</code> are derived per message from the inbound topic or payload.
|
|
|
102
|
</p>
|
|
|
103
|
<p>
|
|
|
104
|
Mapping:
|
|
|
105
|
<code>presence/occupancy + fading_time=0 -> motion/value</code>,
|
|
|
106
|
<code>presence/occupancy + fading_time>0 -> presence/value</code>,
|
|
|
107
|
<code>temperature -> temperature/value</code>,
|
|
|
108
|
<code>humidity -> humidity/value</code>,
|
|
|
109
|
<code>illuminance -> illuminance/value</code>,
|
|
|
110
|
<code>battery -> battery/value</code>,
|
|
|
111
|
<code>battery_low -> battery_low/value</code>,
|
|
|
112
|
<code>tamper -> tamper/value</code>.
|
|
|
113
|
</p>
|
|
|
114
|
<p>
|
|
|
115
|
For this mmWave device, raw Zigbee <code>presence</code> is converted to HomeBus <code>motion</code> when <code>fading_time</code> is <code>0</code>. Device-level <code>presence</code> is published only when the sensor is intentionally configured to hold presence with non-zero <code>fading_time</code>.
|
|
|
116
|
</p>
|
|
|
117
|
<p>
|
|
|
118
|
Identity is resolved with priority:
|
|
|
119
|
incoming topic, then message/payload fields, then fallback defaults
|
|
|
120
|
<code>unknown/unknown/device_type</code>.
|
|
|
121
|
</p>
|
|
|
122
|
<p>
|
|
|
123
|
With the recommended topic structure, <code>site</code>, <code>location</code>, <code>device_id</code>,
|
|
|
124
|
and usually <code>source_ref</code> are inferred directly from the Zigbee2MQTT topic path.
|
|
|
125
|
</p>
|
|
|
126
|
<p>
|
|
|
127
|
If this node is created from an older flow JSON, legacy fields
|
|
|
128
|
<code>mqttBus</code>, <code>mqttRoom</code>, and <code>mqttSensor</code> are still accepted as fallbacks.
|
|
|
129
|
</p>
|
|
|
130
|
<p>
|
|
|
131
|
Malformed or unmappable inputs are routed to adapter operational topics instead of being embedded into semantic bus payloads.
|
|
|
132
|
</p>
|
|
|
133
|
<p>
|
|
|
134
|
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-zg-204zv/{error,dlq}</code>.
|
|
|
135
|
</p>
|
|
|
136
|
</script>
|
|
|
137
|
|
|
|
138
|
<script>
|
|
|
139
|
RED.nodes.registerType("z2m-zg-204zv-homebus", {
|
|
|
140
|
category: "myNodes",
|
|
|
141
|
color: "#d9ecfb",
|
|
|
142
|
defaults: {
|
|
|
143
|
name: { value: "" },
|
|
|
144
|
batteryLowThreshold: { value: 20, validate: RED.validators.number() },
|
|
|
145
|
batteryType: { value: "alkaline" },
|
|
|
146
|
mqttBus: { value: "" },
|
|
|
147
|
mqttRoom: { value: "" },
|
|
|
148
|
mqttSensor: { value: "" }
|
|
|
149
|
},
|
|
|
150
|
inputs: 1,
|
|
|
151
|
outputs: 2,
|
|
|
152
|
icon: "font-awesome/fa-sitemap",
|
|
|
153
|
label: function() {
|
|
|
154
|
return this.name || "z2m-zg-204zv-homebus";
|
|
|
155
|
},
|
|
|
156
|
paletteLabel: "zg-204zv homebus"
|
|
|
157
|
});
|
|
|
158
|
</script>
|