Newer Older
76 lines | 2.866kb
Bogdan Timofte authored 2 weeks ago
1
<script type="text/x-red" data-template-name="smart-socket-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="living-room">
13
  </div>
14
  <div class="form-row">
15
    <label for="node-input-accessory"><i class="fa fa-plug"></i> Accessory</label>
16
    <input type="text" id="node-input-accessory" placeholder="tv">
17
  </div>
18
</script>
19

            
20
<script type="text/x-red" data-help-name="smart-socket-homekit-adapter">
21
  <p>
22
    Consumes canonical HomeBus power telemetry for a single smart socket endpoint and projects it to a HomeKit <code>Outlet</code> service.
23
  </p>
24
  <p>
25
    The node subscribes to:
26
    <code>&lt;site&gt;/home/&lt;location&gt;/power/&lt;accessory&gt;/last</code>,
27
    <code>.../meta</code>,
28
    <code>.../value</code>, and
29
    <code>.../availability</code>.
30
  </p>
31
  <p>
32
    It also accepts HomeKit control messages from the paired <code>homekit-service</code> node and republishes them as canonical HomeBus power commands on:
33
    <code>&lt;site&gt;/home/&lt;location&gt;/power/&lt;accessory&gt;/set</code>
34
  </p>
35
  <p>
36
    Wire the first output of the <code>homekit-service</code> <code>Outlet</code> node back into this adapter input if you want HomeKit toggles to be translated into HomeBus commands.
37
  </p>
38
  <h3>Outputs</h3>
39
  <ol>
40
    <li>HomeKit Outlet payloads, for example <code>{ On: 1, OutletInUse: 1 }</code>.</li>
41
    <li>MQTT-ready canonical HomeBus set publishes.</li>
42
    <li>Dynamic <code>mqtt in</code> control messages for semantic MQTT bootstrap/live subscriptions.</li>
43
  </ol>
44
  <h3>HomeKit Service Setup</h3>
45
  <p><code>Outlet</code></p>
46
  <pre><code>{"OutletInUse":{}}</code></pre>
47
</script>
48

            
49
<script>
50
  function requiredText(v) {
51
    return !!(v && String(v).trim());
52
  }
53

            
54
  RED.nodes.registerType("smart-socket-homekit-adapter", {
55
    category: "myNodes",
56
    color: "#d7f0d1",
57
    defaults: {
58
      name: { value: "" },
59
      outputTopic: { value: "" },
60
      mqttBus: { value: "" },
61
      site: { value: "", validate: requiredText },
62
      location: { value: "", validate: requiredText },
63
      accessory: { value: "", validate: requiredText },
64
      mqttSite: { value: "" },
65
      mqttRoom: { value: "" },
66
      mqttSensor: { value: "" }
67
    },
68
    inputs: 1,
69
    outputs: 3,
70
    icon: "font-awesome/fa-plug",
71
    label: function() {
72
      return this.name || "smart-socket-homekit-adapter";
73
    },
74
    paletteLabel: "smart socket homekit"
75
  });
76
</script>