Zigbee2mqtt: getting rid of your proprietary Zigbee bridges (Xiaomi, Hue, TRADFRI)

If I turn on discovery both on HA and zigbee2mqtt, do devices automatically appear as a sensor on HA?

Within HA configuration.yaml, I have:

mqtt:
  discovery: true

zigbee2mqtt configuration.yaml:
homeassistant: true

I restart Z2M first and then HA. Z2M shows the following in the logs:

Jun 07 20:58:33 zigbeepi npm[934]: 2018-6-7 20:58:33 INFO MQTT publish, topic: 'homeassistant/binary_sensor/0x00158d0001b149eb/contact/config', payload: '{"payload_on":false,"payload_off":true,"value_template":"{{ value_json.contact }}","device_class":"door","json_attributes":["battery","voltage"],"state_topic":"zigbee2mqtt/window_ensuite_velux","availability_topic":"zigbee2mqtt/bridge/state","name":"window_ensuite_velux","unique_id":"0x00158d0001b149eb_contact_zigbee2mqtt"}'

Looking within States on HA, thereā€™s no sensor that looks like this.

Am I misunderstanding how this works? Iā€™m hoping for a sensor entry similar to how Xiaomi works within HA.

I tried the manual method by turning off discover on HA and Z2M, and using the following sensor:

binary_sensor:
  - platform: "mqtt"
    state_topic: "zigbee2mqtt/window_ensuite_velux"
    availability_topic: "zigbee2mqtt/bridge/state"
    payload_on: false
    payload_off: true
    value_template: "{{ value_json.contact }}"
    device_class: "door"
    json_attributes:
      - "battery"
      - "voltage"

This just results in the following entry in States:
binary_sensor.mqtt_binary_sensor off friendly_name: MQTT Binary sensor device_class: door

I think Iā€™m misunderstanding something here? :slight_smile:

1 Like

Start HA with with discover mqtt on, then start zigbee2mqtt and HA will get the string you posted over mqtt and create the devices. check the dev state panel < > and filter off the friendly names you put in the zigbee2mqtt configuration and you should see the devices.

Thanks! Iā€™ll try that this evening.

1 Like

Still have no luck getting the door sensor to display the correct status. Is there anyway to unpair the door sensor and try connecting it again?

Hi All,

Not sure what Iā€™m doing wrong here, I have followed the Getting Started Wiki and flashed the USB sniffer. Then followed the instructions to install the Hassio Add-on for zigbee2mqtt. I have added discovery: true to my mqtt component in HA configuration.yaml. Looking at the logs for the zigbee2mqtt add-on, I see the following repeating over and over. Anyone know whatā€™s going on? Have I missed something in the instructions?

[Info] Configuration file found. Will overwrite configurable fields with values from add-on configuration
[Info] Configuration written to /share/zigbee2mqtt/configuration.yaml
[2018-06-08 22:43:38] PM2 log: Launching in no daemon mode
[2018-06-08 22:43:38] PM2 log: Starting execution sequence in -fork mode- for app name:npm id:0
[2018-06-08 22:43:38] PM2 log: App name:npm id:0 online
[email protected] start /app
node index.js
module.js:538
throw err;
^
Error: Cannot find module ā€˜zcl-packetā€™
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object. (/app/lib/zigbee.js:6:19)
at Module._compile (module.js:635:30)
at Object.Module._extensionsā€¦js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
npm
ERR! code ELIFECYCLE
npm ERR! errno 1
npm
ERR! [email protected] start: node index.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-06-09T05_43_47_403Z-debug.log
[2018-06-08 22:44:05] PM2 log: App [npm] with id [0] and pid [25], exited with code [1] via signal [SIGINT]
[2018-06-08 22:44:05] PM2 log: Starting execution sequence in -fork mode- for app name:npm id:0
[2018-06-08 22:44:05] PM2 log: App name:npm id:0 online
[email protected] start /app
node index.js
module.js:538
throw err;
^
Error: Cannot find module ā€˜zcl-packetā€™
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object. (/app/lib/zigbee.js:6:19)
at Module._compile (module.js:635:30)
at Object.Module._extensionsā€¦js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
npm
ERR! code ELIFECYCLE
npm ERR!
errno 1
npm
ERR! [email protected] start: node index.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-06-09T05_44_14_045Z-debug.log

This can be done by pressing and holding the pairing button for Ā± 5 seconds (until blue light flash). Then repeat pairing procedure.

Nothing! It was a bug in zigbee2mqtt, update by using git pull and do a npm install again.

I get this error constantly

2018-6-9 20:05:42 INFO Starting zigbee-shepherd
2018-6-9 20:05:44 INFO zigbee-shepherd started
2018-6-9 20:05:44 INFO Currently 2 devices are joined:
2018-6-9 20:05:44 INFO unknown (0x00158d0001b93d70): unkown - undefined unknown (EndDevice)
2018-6-9 20:05:44 INFO unknown (0x00158d0001656c78): unkown - undefined unknown (EndDevice)
2018-6-9 20:05:44 INFO Connecting to MQTT server at mqtt://192.168.1.39:1883
2018-6-9 20:05:44 INFO zigbee-shepherd ready
/app/node_modules/zcl-packet/lib/foundation.js:297
dataTypeStr = zclId.dataType(dataType).key;
^
TypeError: Cannot read property ā€˜keyā€™ of undefined
at ensureDataTypeString (/app/node_modules/zcl-packet/lib/foundation.js:297:47)
at getDataType (/app/node_modules/zcl-packet/lib/foundation.js:307:16)
at Dissolve. (/app/node_modules/zcl-packet/lib/foundation.js:646:24)
at Dissolve._transform (/app/node_modules/dissolve/index.js:80:16)
at Dissolve.Transform._read (/app/node_modules/dissolve/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at Dissolve.Transform._write (/app/node_modules/dissolve/node_modules/readable-stream/lib/_stream_transform.js:172:12)
at doWrite (/app/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:279:12)
at writeOrBuffer (/app/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:266:5)
at Dissolve.Writable.write (/app/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:211:11)
at Dissolve.Writable.end (/app/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:426:10)
npm
ERR! code ELIFECYCLE
npm ERR! errno 1
npm
ERR! [email protected] start: node index.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-06-09T18_05_44_875Z-debug.log
[2018-06-09 20:05:54] PM2 log: App [npm] with id [0] and pid [184], exited with code [1] via signal [SIGINT]
[2018-06-09 20:05:54] PM2 log: Starting execution sequence in -fork mode- for app name:npm id:0
[2018-06-09 20:05:54] PM2 log: App name:npm id:0 online

[email protected] start /app
node index.js
2018-6-9 20:05:58 INFO Starting zigbee-shepherd
2018-6-9 20:05:59 INFO zigbee-shepherd started
2018-6-9 20:05:59 INFO Currently 2 devices are joined:
2018-6-9 20:05:59 INFO unknown (0x00158d0001b93d70): unkown - undefined unknown (EndDevice)
2018-6-9 20:05:59 INFO unknown (0x00158d0001656c78): unkown - undefined unknown (EndDevice)
2018-6-9 20:05:59 INFO Connecting to MQTT server at mqtt://192.168.1.39:1883
2018-6-9 20:05:59 INFO zigbee-shepherd ready
2018-6-9 20:06:00 INFO Connected to MQTT server
2018-6-9 20:06:00 INFO MQTT publish, topic: ā€˜zigbee2mqtt/bridge/stateā€™, payload: ā€˜onlineā€™
/app/node_modules/zcl-packet/lib/foundation.js:297
dataTypeStr = zclId.dataType(dataType).key;
^
TypeError: Cannot read property ā€˜keyā€™ of undefined
at ensureDataTypeString (/app/node_modules/zcl-packet/lib/foundation.js:297:47)
at getDataType (/app/node_modules/zcl-packet/lib/foundation.js:307:16)
at Dissolve. (/app/node_modules/zcl-packet/lib/foundation.js:646:24)
at Dissolve._transform (/app/node_modules/dissolve/index.js:80:16)
at Dissolve.Transform._read (/app/node_modules/dissolve/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at Dissolve.Transform._write (/app/node_modules/dissolve/node_modules/readable-stream/lib/_stream_transform.js:172:12)
at doWrite (/app/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:279:12)
at writeOrBuffer (/app/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:266:5)
at Dissolve.Writable.write (/app/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:211:11)
at Dissolve.Writable.end (/app/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:426:10)
npm
ERR! code
ELIFECYCLE
npm ERR! errno 1
npm
ERR! [email protected] start: node index.js
npm ERR!
Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm
ERR! /root/.npm/_logs/2018-06-09T18_08_07_925Z-debug.log
[2018-06-09 20:08:07] PM2 log: App [npm] with id [0] and pid [215], exited with code [1] via signal [SIGINT]
[2018-06-09 20:08:07] PM2 log: Starting execution sequence in -fork mode- for app name:npm id:0
[2018-06-09 20:08:07] PM2 log: App name:npm id:0 online
[email protected] start /app
node index.js
2018-6-9 20:08:12 INFO Starting zigbee-shepherd
2018-6-9 20:08:13 INFO zigbee-shepherd started
2018-6-9 20:08:13 INFO Currently 2 devices are joined:
2018-6-9 20:08:13 INFO unknown (0x00158d0001b93d70): unkown - undefined unknown (EndDevice)
2018-6-9 20:08:13 INFO unknown (0x00158d0001656c78): unkown - undefined unknown (EndDevice)
2018-6-9 20:08:13 INFO Connecting to MQTT server at mqtt://192.168.1.39:1883
2018-6-9 20:08:14 INFO zigbee-shepherd ready
2018-6-9 20:08:14 INFO Connected to MQTT server
2018-6-9 20:08:14 INFO MQTT publish, topic: ā€˜zigbee2mqtt/bridge/stateā€™, payload: ā€˜onlineā€™

Whats the matter?
the 2 devices that are connected are devices that are supported.
im running hass io

Updating to the last version should solve this.

Hey @Koenkk, just wanna express my gratitude for your work and the extensive documentation. Flashing the CC2531 with the CC debugger and integrating an Aqara wireless switch (WXKG02LM) into Home Assistant worked like a breeze! Iā€™m using the provided Docker image btw, thank you for that aswell! :+1:

2 Likes

@Koenkk i tried repairing the door sensor but nothing shows up in my logs. What would happen if i remove the entity within the configuration.yaml file?

This is all iā€™m seeing in my logs.

2018-6-9 19:16:39 INFO Connected to MQTT server
2018-6-9 19:16:39 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/state', payload: 'online'
2018-6-9 19:16:39 WARN `permit_join` set to  `true` in configuration.yaml.
2018-6-9 19:16:39 WARN Allowing new devices to join.
2018-6-9 19:16:39 WARN Set `permit_join` to `false` once you joined all devices.
2018-6-9 19:16:39 INFO Zigbee: allowing new devices to join.
2018-6-9 20:16:42 WARN Soft resetted zigbee
2018-6-9 20:16:42 INFO zigbee-shepherd ready

Could you open an issue here: https://github.com/Koenkk/zigbee2mqtt/issues ?

i reinstalled it and now its working, paired one device succesfully.

1 Like

How do I go about doing that? Iā€™m running Hassio and using the SSH add-on, when I enter git pull, I get the following error.

fatal: Not a git repository (or any of the parent directories): .git

And after a little research, doesnā€™t seem like the Hassio SSH add-on allows the installation of packages or anything as root. Any help would be appreciated. Thanks

Are you using the hassio zigbee2mqtt addon?

Use this documentation: https://github.com/danielwelch/hassio-zigbee2mqtt#updating-the-add-on-and-zigbee2mqtt-library

Yes.

Thatā€™s the documentation I followed, the configuration is the part I was a bit confused about is the mqtt_server. I have used the mqtt brokers local ip plus the port and the default homeassistant plus the port but they all come back with the same errors. Would getting the settings wrong cause these errors?

So you have updated the hassio addon and are having a different problem now?

I have not updated the addon so Iā€™m still having the same exact problem. I donā€™t know how to do the updateā€¦ Iā€™m not able to figure out how to use git pull and npm install as Koenkk had suggested to update the installation.

I use the Hassio SSH addon and type in the command git pull, it gives me this error:

fatal: Not a git repository (or any of the parent directories): .git

Searching around on the error, Iā€™m getting that I donā€™t have a git repository setup. But I donā€™t know where to set that repository nor where to set itā€¦

Please read back in thread and you will see a link to the instructions for hassio, posted by @ciotlosm