|
Bogdan Timofte
authored
2 weeks ago
|
1
|
<script type="text/x-red" data-template-name="pa-44z-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="kitchen">
|
|
|
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="smoke-sensor">
|
|
|
17
|
</div>
|
|
|
18
|
<div class="form-row">
|
|
|
19
|
<label for="node-input-batteryLowThreshold">Battery low threshold (%)</label>
|
|
|
20
|
<input type="number" id="node-input-batteryLowThreshold" min="0" max="100" placeholder="20">
|
|
|
21
|
</div>
|
|
|
22
|
</script>
|
|
|
23
|
|
|
|
24
|
<script type="text/x-red" data-help-name="pa-44z-homekit-adapter">
|
|
|
25
|
<p>
|
|
|
26
|
Consumes HomeBus telemetry for a single <code>PA-44Z</code> smoke detector endpoint and projects it to HomeKit services.
|
|
|
27
|
</p>
|
|
|
28
|
<p>
|
|
|
29
|
Output 3 controls a Node-RED <code>mqtt in</code> node with dynamic subscriptions.
|
|
|
30
|
</p>
|
|
|
31
|
<p>
|
|
|
32
|
On start, the node emits:
|
|
|
33
|
<code>subscribe <site>/home/<location>/+/<accessory>/last</code>,
|
|
|
34
|
<code>subscribe <site>/home/<location>/+/<accessory>/value</code>, and
|
|
|
35
|
<code>subscribe <site>/home/<location>/+/<accessory>/availability</code>.
|
|
|
36
|
</p>
|
|
|
37
|
<p>
|
|
|
38
|
The node keeps <code>.../last</code> subscribed until bootstrap is held open for <code>10s</code>, then emits a complete snapshot and unsubscribes from <code>.../last</code>.
|
|
|
39
|
</p>
|
|
|
40
|
<h3>Capabilities</h3>
|
|
|
41
|
<p>
|
|
|
42
|
Mappings:
|
|
|
43
|
<code>smoke -> Smoke Sensor</code>,
|
|
|
44
|
<code>battery + battery_low -> Battery</code>,
|
|
|
45
|
<code>device_fault -> StatusFault</code>.
|
|
|
46
|
</p>
|
|
|
47
|
<p>
|
|
|
48
|
<code>silence</code>, <code>test</code>, and <code>smoke_concentration</code> are carried on HomeBus but are not exposed to HomeKit by this adapter.
|
|
|
49
|
</p>
|
|
|
50
|
<h3>Outputs</h3>
|
|
|
51
|
<ol>
|
|
|
52
|
<li>Smoke Sensor: <code>{ SmokeDetected, StatusActive, StatusFault, StatusLowBattery }</code></li>
|
|
|
53
|
<li>Battery Service: <code>{ StatusLowBattery, BatteryLevel, ChargingState }</code></li>
|
|
|
54
|
<li><code>mqtt in</code> dynamic control messages: <code>{ action, topic }</code></li>
|
|
|
55
|
</ol>
|
|
|
56
|
<h3>HomeKit Service Setup</h3>
|
|
|
57
|
<p><code>Smoke Sensor</code></p>
|
|
|
58
|
<pre><code>{"StatusActive":{},"StatusFault":{},"StatusLowBattery":{}}</code></pre>
|
|
|
59
|
<p><code>Battery</code></p>
|
|
|
60
|
<pre><code>{"BatteryLevel":{},"ChargingState":{}}</code></pre>
|
|
|
61
|
</script>
|
|
|
62
|
|
|
|
63
|
<script>
|
|
|
64
|
function requiredText(v) {
|
|
|
65
|
return !!(v && String(v).trim());
|
|
|
66
|
}
|
|
|
67
|
|
|
|
68
|
RED.nodes.registerType("pa-44z-homekit-adapter", {
|
|
|
69
|
category: "myNodes",
|
|
|
70
|
color: "#d7f0d1",
|
|
|
71
|
defaults: {
|
|
|
72
|
name: { value: "" },
|
|
|
73
|
outputTopic: { value: "" },
|
|
|
74
|
mqttBus: { value: "" },
|
|
|
75
|
site: { value: "", validate: requiredText },
|
|
|
76
|
location: { value: "", validate: requiredText },
|
|
|
77
|
accessory: { value: "", validate: requiredText },
|
|
|
78
|
mqttSite: { value: "" },
|
|
|
79
|
mqttRoom: { value: "" },
|
|
|
80
|
mqttSensor: { value: "" },
|
|
|
81
|
batteryLowThreshold: { value: 20, validate: RED.validators.number() },
|
|
|
82
|
publishCacheWindowSec: { value: "" }
|
|
|
83
|
},
|
|
|
84
|
inputs: 1,
|
|
|
85
|
outputs: 3,
|
|
|
86
|
icon: "font-awesome/fa-fire-extinguisher",
|
|
|
87
|
label: function() {
|
|
|
88
|
return this.name || "pa-44z-homekit-adapter";
|
|
|
89
|
},
|
|
|
90
|
paletteLabel: "pa-44z homekit"
|
|
|
91
|
});
|
|
|
92
|
</script>
|