|
Bogdan Timofte
authored
2 weeks ago
|
1
|
<script type="text/x-red" data-template-name="snzb-04p-homekit-adapter">
|
|
|
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="vad">
|
|
|
9
|
</div>
|
|
|
10
|
<div class="form-row">
|
|
|
11
|
<label for="node-input-location"><i class="fa fa-home"></i> Location</label>
|
|
|
12
|
<input type="text" id="node-input-location" placeholder="entry">
|
|
|
13
|
</div>
|
|
|
14
|
<div class="form-row">
|
|
|
15
|
<label for="node-input-accessory"><i class="fa fa-dot-circle-o"></i> Accessory</label>
|
|
|
16
|
<input type="text" id="node-input-accessory" placeholder="front-door">
|
|
|
17
|
</div>
|
|
|
18
|
<div class="form-row">
|
|
|
19
|
<label for="node-input-sensorUsage">Usage</label>
|
|
|
20
|
<select id="node-input-sensorUsage">
|
|
|
21
|
<option value="door-window">Door / Window sensor</option>
|
|
|
22
|
<option value="contact">Generic contact sensor</option>
|
|
|
23
|
<option value="dual-contact">Dual contact: magnetic + mechanical</option>
|
|
|
24
|
</select>
|
|
|
25
|
</div>
|
|
|
26
|
<div class="form-row">
|
|
|
27
|
<label for="node-input-batteryLowThreshold">Battery low threshold (%)</label>
|
|
|
28
|
<input type="number" id="node-input-batteryLowThreshold" min="0" max="100" placeholder="20">
|
|
|
29
|
</div>
|
|
|
30
|
</script>
|
|
|
31
|
|
|
|
32
|
<script type="text/x-red" data-help-name="snzb-04p-homekit-adapter">
|
|
|
33
|
<p>
|
|
|
34
|
Consumes HomeBus telemetry for a single <code>SNZB-04P</code> endpoint and projects it to HomeKit services.
|
|
|
35
|
</p>
|
|
|
36
|
<p>
|
|
|
37
|
This adapter supports three usage modes. In all cases the HomeKit service type remains <code>ContactSensor</code>;
|
|
|
38
|
the usage setting documents the intended role of the device in the flow and controls whether a secondary contact output is emitted.
|
|
|
39
|
</p>
|
|
|
40
|
<p>
|
|
|
41
|
<code>Door / Window sensor</code>: use the magnetic contact as the primary contact sensor for doors and windows.
|
|
|
42
|
</p>
|
|
|
43
|
<p>
|
|
|
44
|
<code>Generic contact sensor</code>: use the same primary contact output where the endpoint is not modeled as a door or window in the flow.
|
|
|
45
|
</p>
|
|
|
46
|
<p>
|
|
|
47
|
<code>Dual contact: magnetic + mechanical</code>: expose the magnetic contact on output 1 and the mechanical/tamper contact on output 2.
|
|
|
48
|
</p>
|
|
|
49
|
<p>
|
|
|
50
|
Mappings:
|
|
|
51
|
<code>contact -> Contact Sensor</code>,
|
|
|
52
|
<code>battery + battery_low -> Battery</code>,
|
|
|
53
|
and in <code>dual-contact</code> mode <code>tamper -> secondary Contact Sensor</code>.
|
|
|
54
|
Optional <code>tamper</code> updates are folded into HomeKit status flags when available.
|
|
|
55
|
</p>
|
|
|
56
|
<ol>
|
|
|
57
|
<li>Contact magnetic: <code>{ ContactSensorState, StatusActive, StatusFault, StatusLowBattery, StatusTampered }</code></li>
|
|
|
58
|
<li>Contact mecanic din <code>tamper</code> in modul <code>dual-contact</code>: <code>{ ContactSensorState, StatusActive, StatusFault, StatusLowBattery, StatusTampered }</code></li>
|
|
|
59
|
<li>Battery Service: <code>{ StatusLowBattery, BatteryLevel, ChargingState }</code></li>
|
|
|
60
|
<li><code>mqtt in</code> dynamic control messages: <code>{ action, topic }</code></li>
|
|
|
61
|
</ol>
|
|
|
62
|
<h3>HomeKit Service Setup</h3>
|
|
|
63
|
<p><code>Battery</code></p>
|
|
|
64
|
<pre><code>{"BatteryLevel":{},"ChargingState":{}}</code></pre>
|
|
|
65
|
<p><code>Contact</code></p>
|
|
|
66
|
<pre><code>{"StatusActive":{},"StatusFault":{},"StatusLowBattery":{},"StatusTampered":{}}</code></pre>
|
|
|
67
|
<p><code>Secondary contact</code> in <code>dual-contact</code> mode</p>
|
|
|
68
|
<pre><code>{"StatusActive":{},"StatusFault":{},"StatusLowBattery":{},"StatusTampered":{}}</code></pre>
|
|
|
69
|
</script>
|
|
|
70
|
|
|
|
71
|
<script>
|
|
|
72
|
function requiredText(v) {
|
|
|
73
|
return !!(v && String(v).trim());
|
|
|
74
|
}
|
|
|
75
|
|
|
|
76
|
RED.nodes.registerType("snzb-04p-homekit-adapter", {
|
|
|
77
|
category: "myNodes",
|
|
|
78
|
color: "#d7f0d1",
|
|
|
79
|
defaults: {
|
|
|
80
|
name: { value: "" },
|
|
|
81
|
outputTopic: { value: "" },
|
|
|
82
|
mqttBus: { value: "" },
|
|
|
83
|
site: { value: "", validate: requiredText },
|
|
|
84
|
location: { value: "", validate: requiredText },
|
|
|
85
|
accessory: { value: "", validate: requiredText },
|
|
|
86
|
sensorUsage: { value: "door-window" },
|
|
|
87
|
mqttSite: { value: "" },
|
|
|
88
|
mqttRoom: { value: "" },
|
|
|
89
|
mqttSensor: { value: "" },
|
|
|
90
|
batteryLowThreshold: { value: 20, validate: RED.validators.number() },
|
|
|
91
|
publishCacheWindowSec: { value: "" }
|
|
|
92
|
},
|
|
|
93
|
inputs: 1,
|
|
|
94
|
outputs: 4,
|
|
|
95
|
icon: "font-awesome/fa-exchange",
|
|
|
96
|
label: function() {
|
|
|
97
|
return this.name || "snzb-04p-homekit-adapter";
|
|
|
98
|
},
|
|
|
99
|
paletteLabel: "snzb-04p homekit"
|
|
|
100
|
});
|
|
|
101
|
</script>
|