1 contributor
66 lines | 2.294kb
<script type="text/x-red" data-template-name="z2m-snzb-04p-homebus">
  <div class="form-row">
    <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
    <input type="text" id="node-input-name" placeholder="Name">
  </div>
  <div class="form-row">
    <label for="node-input-site"><i class="fa fa-globe"></i> Site</label>
    <input type="text" id="node-input-site" placeholder="unknown">
  </div>
  <div class="form-row">
    <label for="node-input-batteryLowThreshold">Battery low threshold (%)</label>
    <input type="number" id="node-input-batteryLowThreshold" min="0" max="100" placeholder="20">
  </div>
</script>

<script type="text/x-red" data-help-name="z2m-snzb-04p-homebus">
  <p>
    Translates Zigbee2MQTT messages for SONOFF <code>SNZB-04P</code> contact sensors into canonical HomeBus topics.
  </p>
  <p>
    Canonical topic shape:
    <code>&lt;site&gt;/home/&lt;location&gt;/&lt;capability&gt;/&lt;device_id&gt;/&lt;stream&gt;</code>
  </p>
  <p>
    Example outputs:
    <code>vad/home/entry/contact/front-door/value</code>,
    <code>vad/home/entry/battery/front-door/last</code>,
    <code>vad/home/entry/contact/front-door/meta</code>
  </p>
  <p>
    Expected Zigbee2MQTT telemetry topic:
    <code>zigbee2mqtt/SNZB-04P/&lt;site&gt;/&lt;location&gt;/&lt;device_id&gt;</code>.
  </p>
  <p>
    Used fields:
    <code>contact</code>, <code>battery</code>, <code>battery_low</code>, <code>voltage</code>,
    <code>tamper</code>, <code>availability</code>, <code>online</code>.
  </p>
  <ol>
    <li>MQTT-ready publish messages, emitted as an array.</li>
    <li><code>mqtt in</code> control messages for the raw Zigbee2MQTT subscription.</li>
  </ol>
</script>

<script>
  RED.nodes.registerType("z2m-snzb-04p-homebus", {
    category: "myNodes",
    color: "#d9ecfb",
    defaults: {
      name: { value: "" },
      site: { value: "unknown" },
      batteryLowThreshold: { value: 20, validate: RED.validators.number() },
      mqttSite: { value: "" },
      mqttBus: { value: "" },
      mqttRoom: { value: "" },
      mqttSensor: { value: "" }
    },
    inputs: 1,
    outputs: 2,
    icon: "font-awesome/fa-sitemap",
    label: function() {
      return this.name || "z2m-snzb-04p-homebus";
    },
    paletteLabel: "snzb-04p homebus"
  });
</script>