Giter Club home page Giter Club logo

homebridge-tasmota-zbbridge's Introduction

verified-by-homebridge npm npm GitHub pull requests GitHub issues

Homebridge Tasmota Zigbee Bridge

This Homebridge plugin can controll Tasmota or Zigbee devices connected to a MQTT broker.

Devices flashed with Tasmota firmware (Outlet Switch, Lightbulb, RGB Stripe, Sensor, etc.) are suported directly. Zigbee devices can be controlled using Zigbee2Tasmota or Zigbee2MQTT gateway/bridge.

By configuring a powerTopic it is possible to combine devices to a singe HomeKit appliance - Tasmota controlled switch can turn on a Zigbee lightbulb and then change the brightness or the collor over the Zigbee network (the lightbulb should be configured to turn on automatically when power is applied).

Installation

  • Flash your device(s) with Tasmota
  • 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",
    "zigbee2TasmotaDevices": [
        {
            "addr": "0x8E8E",
            "type": "light1",
            "name": "Hue Lamp",
            "powerTopic": "shelly-kitchen",
            "powerType": "POWER2"
        },
        {
            "addr": "0x001788011234567F",
            "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 Outlet"
        },
        {
            "addr": "0x43D0",
            "type": "sensor",
            "name": "Garage Door",
            "sensorService": "ContactSensor",
            "sensorCharacteristic": "ContactSensorState",
            "sensorValuePath": "Contact"
        },
        {
            "addr": "0xD394",
            "type": "sensor",
            "name": "Sensor3",
            "sensorService": "StatelessProgrammableSwitch",
            "sensorValuePath": "Click",
            "sensorValueMapping": [
                {
                    "from": "single",
                    "to": "0"
                },
                {
                    "from": "double",
                    "to": "1"
                },
                {
                    "from": "hold",
                    "to": "2"
                }
            ]
        }
    ],
    "zigbee2mqttDevices": [
        {
            "ieee_address": "0x002788011234567F",
            "name": "Light Bulb"
        }
    ],
    "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",
    "zigbee2tasmotaTopic": "zbbridge",
    "zigbee2mqttTopic": "zigbee2mqtt",
    "platform": "TasmotaZbBridge"
}

zigbee2TasmotaDevices - Zigbee devices connected to the Zigbee2Tasmota gateway/bridge

  • addr - Device hardware or short address and optional endpoint (for example Tuya 2ch switch). The hardware address (64 bits) is unique per device and factory assigned so once configured it will still work even if the device have to be paired again. Example: Use 0xAC3C:1 for address 0xAC3C, endpoint 1.
  • type - Device type (light0, light1, light2, light3, light4, light5, switch, sensor) see descriptions in config.schema.json. Alternatively use generic light adding supported features: _B for brigthness, _CT for color temperature, _HS for hue and saturation and _XY for XY color support (for example light_B_CT_XY). Configure desired sensor type using the specific fields below.
  • name - Accessory name to be used in the Home applicaiton. Should be unique. Will update ZbBridge Friendly Name if endpoint is not used.
  • Advanced settings
    • powerTopic - (optional) Use another tasmota device to controll the power (configure it's identifying topic)

    • powerType - (optional) Tasmota switch topic used to turn on/off the zigbee device, (default: POWER)

    • sensorService - (optional) Sensor service name as defined here (default: ContactSensor)

    • sensorCharacteristic - (optional) Service characteristic name (default: ContactSensorState)

    • sensorValuePath - (optional) Path of the sensor value in the SENSOR message (default: Contact).

    • sensorValueMapping - (optional) Map sensor from value to homebridge to value. All other values will be ignored.

      For example CONTACT_DETECTED will be reported when following message is received:

      {"ZbReceived":{"0x43D0":{"Device":"0x43D0","Name":"ContactSensorExample","Contact":0,"Endpoint":1,"LinkQuality":66}}}
      

zigbee2mqttDevices - Zigbee devices connected to Zigbee2MQTT gateway/bridge

  • ieee_address
  • name - Accessory name to be used in the Home applicaiton. Should be unique.
  • powerTopic - (optional) Use another tasmota device to controll the power (configure it's identifying topic)
  • powerType - (optional) Tasmota switch topic used to turn on/off the zigbee device, (default: POWER)

tasmotaDevices - Tasmota flashed devices

  • topic - Device topic as configured in the MQTT menu
  • type - Device type (POWER, LIGHT, 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 password protected

mqttPassword - MQTT Broker passwort if password protected

zigbee2tasmotaTopic - Zigbee2Tasmota gateway/bridge base topic (default: zbbridge)

zigbee2mqttTopic - Zigbee2MQTT gateway/bridge base topic (default: zigbee2mqtt)

Zigbee2MQTT

It is also possible to controll devices using Zigbee2MQTT gateway/bridge. This is useful if you want to combine Zigbee and Tasmota devices using the powerTopic.

Almost all accessory-types are supported but currently some characteristics are not mapped correctly (work in progress). Supported features are queried directly from Zigbe2MQTT and configured automatically.

Binding with Zigbee2Tasmota

You can add switches or sensors 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 (with old firmware) 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

homebridge-tasmota-zbbridge's People

Contributors

dependabot[bot] avatar mareker avatar mdaskalov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

bluefangs mareker

homebridge-tasmota-zbbridge's Issues

Adaptive lighting support

Describe the solution you'd like:
It would be great to support HomeKit Adaptive Lighting, in-line with similar homebridge plugins eg homebridge-mqtthing.

Additional context:
This would enable the colour temperature of lighting to change in-line with the time of day.

Support more than 4 Switches

Hello, would it be possible for me to control more than 4 different switches on a Tasmota device? I have an ESP32 with 16 switches. I'd like to be able to control them all.

Subsequent button presses ignored

When using a ProgrammableSwitchEvent Sensor, the first button press triggers the event, but subsequent ones do not.

To Reproduce:
Add a ProgrammableSwitchEvent sensor, trigger the event, then try to trigger it again.

Plugin Config:

{
    "name": "ZbBridge",
    "mqttTopic": "zbbridge",
    "zbBridgeDevices": [
        {
            "addr": "0x7EC5",
            "type": "sensor",
            "name": "Moes Scene Switch",
            "sensorService": "StatelessProgrammableSwitch",
            "sensorCharacteristic": "ProgrammableSwitchEvent",
            "sensorValuePath": "LidlPower"
        },
    ],
    "mqttBroker": "localhost",
    "platform": "TasmotaZbBridge"
}

Bug specifics;
In zbBridgeSensor.js, onStatusUpdate, there is a check for "value !== this.value". This makes sense for sensor updates that aren't events, but prevents events being send where the event type is the same as the last.

Button support

Hi, sorry if what I'm asking is silly or obvious…
I've just flashed my ZB-GW03 and paired a couple of devices. Lights work as expected, but I see no way of making buttons appear on the Home App. I've paired an Aqara Wireless Switch D1 and an IKEA Trådfri shortcut button. Both show up in the Tasmota web interface correctly, but when exposed to HomeKit they appear as switches, not buttons, so I can't asign scenes to them.
Am I doing something wrong?

Thanks a lot!

Plugin Config:

{
            "name": "Tasmota ZbBridge",
            "mqttTopic": "tasmota_D2C9C0",
            "zbBridgeDevices": [
                {
                    "addr": "0xB8ED",
                    "type": "light0",
                    "name": "Neón Cocina"
                },
                {
                    "addr": "0xAACF",
                    "type": "switch",
                    "name": "Dormitorio Interruptor Entrada"
                },
                {
                    "addr": "0xDA5C",
                    "type": "switch",
                    "name": "IKEA1"
                }
            ],
            "mqttBroker": "192.168.1.100:1883",
            "platform": "TasmotaZbBridge"
        }

Environment:

  • Plugin Version: v1.1.0
  • Homebridge Version: v1.4.1
  • Node.js Version: v16.15.0
  • NPM Version: v8.5.5
  • Operating System: Docker

Aqara Mini Switch not working

Hi,
i have an Sonoff Zbbridge flashed with Tasmota and connected an Aqara WXKG11LM like this one

https://zigbee.blakadder.com/Aqara_WXKG11LM.html

Zigbee join did work, and connection to mosquito seems to be working too.

But I can't get those MQTT Data to work with my other devices like a like bulb

My goal is to push a button and switch on a light bulb

Logs:

[16.12.2022, 20:55:53] [tasmota_E32163] Restoring ZbBridge accessory: Sensor3 (0x00158D0008747677) - sensor
[16.12.2022, 20:55:53] [tasmota_E32163] Cleanup - configured 1, cached 1 accessories.

Plugin Config:

{
"name": "tasmota_E32163",
"mqttTopic": "tasmota_E32163",
"zbBridgeDevices": [
{
"addr": "0x00158D0008747677",
"type": "sensor",
"name": "Sensor3",
"sensorService": "StatelessProgrammableSwitch",
"sensorValuePath": "Click"
}
],
"platform": "TasmotaZbBridge"
}

Screenshots:
Bildschirm­foto 2022-12-16 um 21 11 50

Environment:

  • Plugin Version:
  • Homebridge Version: 1.6.0
  • Node.js Version: v14.21.1
  • NPM Version:9.2.0
  • Operating System: Debian /

Support for a Motion Sensor?

Hello, first of all great work so far. What I am currently missing is the ability to add a Zigbee motion detector. I currently have one from Sonoff (SNZB-03). When a movement is detected, I get the following messages in the console:

18:27:59.008 ZIG: {"ZbEZSPReceived":"450000040100050101000000003B80BC7261FFFF0919DC00010000010000"}

18:27:59.011 ZIG: {"ZbZCLReceived":{"groupid":0,"clusterid":"0x0500","srcaddr":"0x6172","srcendpoint":1,"dstendpoint":1,"wasbroadcast":0,"LinkQuality":50,"securityuse":0,"seqnumber":59,"fc":"0x19","frametype":1,"direction":1,"disableresp":1,"manuf":"0x0000","transact":220,"cmdid":"0x00","payload":"010000010000"}}

18:27:59.014 ZIG: ZbZCLRawReceived: {"0x6172":{"0500<00":"010000010000","ZoneStatusChange":1,"ZoneStatusChangeZone":1,"0406/0000":1,"Endpoint":1,"LinkQuality":50}}

18:27:59.020 MQT: tele/tasmota_E30562/SENSOR = {"ZbReceived":{"0x6172":{"Device":"0x6172","Name":"Bewegungssensor","0500<00":"010000010000","ZoneStatusChange":1,"ZoneStatusChangeZone":1,"Occupancy":1,"Endpoint":1,"LinkQuality":50}}}

Ignore Tasmota accessory if already configured

Describe The Bug:
Homebridge fails to start if a tasmota device is configured twice with the same topic and type

Expected behavior:
Check if already configured and ignore if so.

Logs:

[28/04/2024, 12:41:44] [homebridge-tasmota-zbbridge] This plugin threw an error from the characteristic 'On': Unhandled error thrown inside read handler for characteristic: This callback function has already been called by someone else; it can only be called one time.. See https://homebridge.io/w/JtMGR for more info.

Plugin Config:

        {
            "topic": "topic",
            "type": "LIGHT",
            "name": "Light1"
        },
        {
            "topic": "topic",
            "type": "LIGHT",
            "name": "Light2"
        },

Having issues adding motion and temp/humidity sensor

First of all, great plug in! I managed to get my contact sensor working correctly (working in home bridge/homekit) following your example, but I can't seem to get my sonoff motion sensor or temp/humidty sensor to work properly. I'm unsure of the sensorvaluecharacteristics or sensorValuePath that I should be using for these. Any help would be greatly appreciated!

After updating to 1.5.0 only one of two contact sensors works

Describe Your Problem:

I have problems with 2 contact sensors in my configuration. First they worked ok but recently I noticed one was stopping reporting state changes. So I removed both and added them again. Then just one was added as an accessory, completely ignoring the second one. Solution was to roll back to plugin version 1.4.4 and add the sensors again. Now it works all fine again. Updating to 1.5.0 brings back the issue. Hope you can fix it in upcoming versions! Otherwise it is a great plugin!

Logs:

[16/10/2022, 16:47:24] [ZbBridge] Executed didFinishLaunching callback
[16/10/2022, 16:47:24] [ZbBridge] MQTT subscribe: zigbee2mqtt/bridge/devices, m5ll9bgos2t
[16/10/2022, 16:47:24] [ZbBridge] MQTT: Published: cmnd/tasmota_E31E7B/zbname 0x00124B002512381C,Schlafzimmertür
[16/10/2022, 16:47:24] [ZbBridge] MQTT: Published: cmnd/tasmota_E31E7B/zbinfo 0x00124B002512381C
[16/10/2022, 16:47:24] [ZbBridge] Restoring zbBridge accessory: Schlafzimmertür (0x00124B002512381C) - sensor

Plugin Config:

        "zbBridgeDevices": [
            {
                "addr": "0x00124B00251228FD",
                "type": "sensor",
                "name": "Wohnzimmertür",
                "sensorService": "ContactSensor",
                "sensorCharacteristic": "ContactSensorState",
                "sensorValuePath": "Contact"
            },
            {
                "addr": "0x00124B002512381C",
                "type": "sensor",
                "name": "Schlafzimmertür",
                "sensorService": "ContactSensor",
                "sensorCharacteristic": "ContactSensorState",
                "sensorValuePath": "Contact"
            }
        ],

Environment:

  • Plugin Version: 1.5.0
  • Homebridge Version: v1.5.0
  • Node.js Version: v16.18.0
  • NPM Version: 8.19.2
  • Operating System: Raspbian

Can't connect to matt broker after updating to 1.9.0

I've been avoiding the latest update because of the "Breaking changes" warning, but ultimately decided to try it today.
I did lose all of my devices (I'm just that clumsy), but didn't mind to add them again.
The problem is that the plugin doesn't seem to connect to my mqtt broker anymore, I get this message.

[ZbBridge] MQTT: Error: getaddrinfo ENOTFOUND host

The hostname box in the setup is marked in red now, not sure why…
screenshot

Any help is welcome!!

Environment:

  • Plugin Version: 1.9.0
  • Homebridge Version: 1.4.1
  • Node.js Version: v18.13.0
  • Operating System: DSM 7.2-64570 Update 3

Osram LIGHTIFY ClA60 RGBW LED doesn't work properly

@mdaskalov: first of all: thanks a lot for the plugin. although the plugin has been around for a while, I only discovered it now.

I have integrated my previous zigbee devices (temperature sensors) into homebridge using mqttthings, but I want to move them to your plugin when the time comes.
I was once able to successfully control my rgb lamp via my CC2531. Since moving to the ZbBridge, I have no longer been able to manage the colour selection. I was therefore very pleased about your plugin.
However, I have two problems:

  1. i can only switch the lamp on and off, setting the colour does not work. in homekit i cannot change the colour (the buttons are displayed slightly pale and cannot be selected).
  2. after switching on the lamp via a normal light switch, the changed state (on) is not displayed in homekit. the button remains as switched off

I tried:

  1. Changing between "RGB light" and "RGB (with XY...)"
  2. in ZbBridge console changing "zblight 0x4c9a,3 (RGB light) and 4 (RGBW light)

both didn`t help
What else can i do?

thank you in advance

Plugin Config:
{
"name": "ZbBridge",
"mqttTopic": "zbbridge",
"zbBridgeDevices": [
{
"addr": "0x4c9a",
"type": "light3",
"name": "Licht_Flur"
}
],
"mqttBroker": "192.168.1.51",
"platform": "TasmotaZbBridge"
}

Environment:

  • Plugin Version: latest
  • Homebridge Version: latest
  • Node.js Version: latest
  • NPM Version: latest
  • Operating System:
    PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
    version 10.11

[Question] Is a Sonoff SNZB-04 ZigBee Wireless Door/Window Sensor supported?

I plan to buy a sonoff zigbee bridge and flash it with tasmota. I already have a few sonoff mini switches that work via mqtt, integrating with homebridge via the Homebridge Mqttthing plugin.

Recently I came across Sonoff SNZB-04 ZigBee Wireless Door/Window Sensor
and would like to buy a few of them. Since they do not have a direct Wifi connectivity, I will also need to buy their Zigbee bridge, which I will flash tasmota on.

My question is, after flashing tasmota on the bridge, how do I add the door sensor to this? Is there support for this specific model?

Thanks!

Environment:

  • Plugin Version: Latest available
  • Homebridge Version: Latest available
  • Node.js Version: v14.16.0
  • NPM Version: 6.14.11
  • Operating System: Rasbian / Pi 3B+

Multiple Sensor Endpoints under one Accessory

Describe the solution you'd like:
It would be good if multiple sense endpoints, eg. buttons on a single switch, could show up as characteristics on the same accessory, rather than separate accessories. I believe this would make more sense semantically.

Support for white temperature?

Hi,
I have bought a light bulb with an option for the white color temperature but the device created does not expose a control for it. In the source code I don't see any commands for it? Am I missing anything?

Aqara Contact Sensors Only Report Open State

Hello,

I have started using this plugin with some zigbee outlets and Aqara door sensors. The outlets are working perfectly, however the Aqara contact sensors never report in a closed state. So, they appear to be constantly open. Here is an example of the console output on the Sonoff Taamota bridge:

01:26:34.695 MQT: tele/tasmota_E1890E/5FA7/SENSOR = {"ZbReceived":{"0x5FA7":{"Device":"0x5FA7","Name":"Garage Entry Door Sensor","Contact":1,"Endpoint":1,"LinkQuality":66}}}

01:26:38.485 MQT: tele/tasmota_E1890E/5FA7/SENSOR = {"ZbReceived":{"0x5FA7":{"Device":"0x5FA7","Name":"Garage Entry Door Sensor","Contact":0,"Endpoint":1,"LinkQuality":66}}}

What can I change to make the plugin process the second message? Thanks in advance for any help you can provide..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.