homebridge-tasmota-zbbridge

Control Zigbee Devices Using Tasmota ZbBridge

Usage no npm install needed!

<script type="module">
  import homebridgeTasmotaZbbridge from 'https://cdn.skypack.dev/homebridge-tasmota-zbbridge';
</script>

README

npm npm GitHub pull requests GitHub issues

Homebridge Tasmota ZbBridge

Thsis plugin can controll zigbee devices connected to Sonoff Zigbee Bridge or any other device running Tasmota firmware using MQTT commands. Requires MQTT broker to communicate.

It is also possible to combine devices - tasmota device can be used to switch a zigbee device on/off.

Installation

  • Flash your device with Tasmota firmware
  • Install homebridge npm install -g homebridge
  • Install the plugin npm install -g homebridge-tasmota-zbbridge
  • Alternatively use the great Homebridge Config UI X plugin to install and configure

Configuration

{
    "name": "ZbBridge",
    "zbBridgeDevices": [
        {
            "addr": "0x8e8e",
            "type": "light1",
            "name": "Hue Lamp",
            "powerTopic": "shelly-kitchen",
            "powerType": "POWER2"
        },
        {
            "addr": "0x6769",
            "type": "light3",
            "name": "Go"
        },
        {
            "addr": "0xAC3C:1",
            "type": "switch",
            "name": "Switch-1",
        },
        {
            "addr": "0xAC3C:2",
            "type": "switch",
            "name": "Switch-2",
        },
        {
            "addr": "0xAD0B",
            "type": "switch",
            "name": "Kitchen Ligths"
        }
    ],
    "tasmotaDevices": [
        {
            "topic": "sonoff",
            "type": "POWER",
            "name": "Sonoff TM"
        },
        {
            "topic": "sonoff",
            "type": "StatusSNS.AM2301.Temperature",
            "name": "Sonoff TM Temperature"
        },
        {
            "topic": "sonoff",
            "type": "StatusSNS.AM2301.Humidity",
            "name": "Sonoff TM Humidity"
        },
        {
            "topic": "sonoff-4ch",
            "type": "POWER2",
            "name": "Sonoff 4CH Channel 2"
        }
    ],
    "mqttBroker": "raspi2",
    "platform": "TasmotaZbBridge"
}

mqttTopic- Identifying topic of your ZbBridge device (i.e. tasmota_ABCDEF)

zbBridgeDevices - Zigbee devices connected to the Sonoff Zigbee Bridge

  • addr - Device short address and optional endpoint (for example Tuya 2ch switch). Use 0xAC3C:1 for address 0xAC3C, endpoint 1.
  • type - Device type (light0, light1, light2, light3, switch) see descriptions in config.schema.json. Alternatively use generic light and add features as needed: _B for brigthness, _CT for color temperature, _HS for hue and saturation and _XY for XY color support. Generic sennsors are suported by defining the type as follows: sensor_<Cluster>_<ReadCommand>_<Service>_<Characteristic>_<ValuePath>
  • name - Accessory name to be used in the Home applicaiton. Should be unique. Will update ZbBridge Friendly Name if endpoint is not used.
  • powerTopic - (optional) Use another tasmota device to controll the power
  • powerType - (optional) Tasmota switch to use, default: POWER

tasmotaDevices - Tasmota flashed devices

  • topic - Device topic as configured in the MQTT menu
  • type - Device type (POWER, StatusSNS.AM2301.Temperature, StatusSNS.AM2301.Humidity, etc.) see descriptions in config.schema.json
  • name - Accessory name to be used in the Home applicaiton. Should be unique.

mqttBroker - MQTT Broker hostname if not localhost

mqttUsername - MQTT Broker username if passwort protected

mqttPassword - MQTT Broker passwort if passwort protected

Binding

You can add switches to HomeKit to control automations or bind them with other devices or groups for direct control.

Note: when a device is bound to a group you have to listen to the group messages for device status updates. By default EZSP will not report group messages unless you subscribe to the group.

IKEA remotes only support 1 group and can be linked to a light only via group numbers (no direct binding).

Type following commands in the tasmota console to bind a switch to a light:

  1. Add the light to group 10
ZbSend {"device":"IKEA_Light","Send":{"AddGroup":10}}
  1. Bind the remote to group 10. Note: you need to press a button on the remote right before sending this command to make sure it's not in sleep mode
ZbBind {"Device":"IKEA_Remote","ToGroup":10,"Cluster":6}
  1. Activate EZSP to listen to the group messages so the HomeKit device is updated each time a group command is received (Not necessary for CC2530 devices)
ZbListen1 10

You can also bind devices as usual using the link button. Then you have to find out the automatically generated group and activate EZSP to listen to this group:

  1. Get all device groups:
ZbSend {"device":"IKEA_Light","Send":{"GetAllGroups":true}}
tele/zbbridge/SENSOR = {"ZbReceived":{"0x303F":{"Device":"0x303F","Name":"IKEA_Light","0004<02":"FF01AFE0","GetGroupCapacity":255,"GetGroupCount":1,"GetGroup":[57519],"Endpoint":1,"LinkQuality":108}}}
  1. Activate EZSP to listen to the group messages for the reported group (Not necessary for CC2530 devices)
ZbListen1 57519

The listen commands should be executed after each reboot. Alternatively a rule to execute them when the zigbee is initialized on boot could be created:

  1. Create the rule:
RULE1 ON ZbState#status=0 DO Backlog ZbListen1 10; ZbListen2 57519 ENDON
  1. Activate it:
RULE1 1