Zigbee2MQTT on HomeAssistant in Docker with Supervisor and custom Devices.js

As usual with anything even remotely related to Linux – nothing is ever simple. I recently got a Raspberry Pi 4 8GB and wanted to install Home Assistant. I believe I did successfully install Home Assistant at least 4 different ways before deciding that the ‘Officially Unsupported’ ‘Supervised’ Raspbian install was what I was looking for. This allowed me to continue using the Raspbian GUI, but also allowed for Supervised Home assistant.

That install has been working fine, however, I’ve just bought a Tuya Zigbee Thermostatic Radiator Valve (TRV) from EBay and wanted to try to integrate it with Home Assistant. The one I bought doesn’t appear to be currently supported by Zigbee2MQTT library, however there are plenty of other Tuya TRVs which are.

So, I believe I need to set up a custom devices.js file. Which there are a lot of instructions for, none of which described my home assistant set up exactly. So – down the rabbit hole we go.

Ok – After many hours of browsing, attempting different configurations and general head banging – it turns out that there’s a bug in the latest version of Zigbee2MQTT (1.16.1) which causes it not to read the ‘devices.js’ file correctly. Which means the first way I tried would have worked, had I known there was a bug… Oh well. This is the second time a bug in HA/addons has royally confused me for hours before realising it wasn’t me

So, now the steps appear to be relatively simple – at least for the moment.

Step 1

Uninstall Zigbee2MQTT and install the ‘Edge’ version which is the latest dev version

Step 2

Create a ‘YOURDEVICENAME.js’ file in /usr/share/hassio/share/zigbee2mqtt (this is easy if you’ve already got SAMBA enabled, then it’s just \share\zigbee2mqtt) and copy the contents from one of the example files here (you can also follow the instructions from here from now I believe)

Step 3

Add the following to your Zigbee2MQTT Configuration:

  log_level: debug

Restart Zigbee2MQTT

Step 4

Go to the Zigbee2MQTT Log and read the messages, you’ll probably see something like:

Zigbee2MQTT:debug 2020-11-30 22:50:28: Received MQTT message on 'zigbee2mqtt/bridge/config' with data '{"commit":"15d04ed","coordinator":{"meta":{"maintrel":3,"majorrel":2,"minorrel":6,"product":0,"revision":20180507,"transportrev":2},"type":"zStack12"},"log_level":"debug","network":{"channel":11,"extendedPanID":"0xdddddddddddddddd","panID":6754},"permit_join":true,"version":"1.16.1-dev"}'
Zigbee2MQTT:info  2020-11-30 22:50:28: MQTT publish: topic 'zigbee2mqtt/bridge/config', payload '{"commit":"15d04ed","coordinator":{"meta":{"maintrel":3,"majorrel":2,"minorrel":6,"product":0,"revision":20180507,"transportrev":2},"type":"zStack12"},"log_level":"debug","network":{"channel":11,"extendedPanID":"0xdddddddddddddddd","panID":6754},"permit_join":true,"version":"1.16.1-dev"}'
Zigbee2MQTT:debug 2020-11-30 22:50:30: Received Zigbee message from '0x5c0272fffef143a4', type 'commandSetTimeRequest', cluster 'manuSpecificTuya', data '{"payload":[],"payloadSize":0}' from endpoint 1 with groupID 0
Zigbee2MQTT:warn  2020-11-30 22:50:30: Received message from unsupported device with Zigbee model 'TS0601' and manufacturer name '_TZE200_fhn3negr'
Zigbee2MQTT:warn  2020-11-30 22:50:30: Please see: https://www.zigbee2mqtt.io/how_tos/how_to_support_new_devices.html.
Zigbee2MQTT:debug 2020-11-30 22:50:36: Received Zigbee message from '0x5c0272fffef143a4', type 'commandSetTimeRequest', cluster 'manuSpecificTuya', data '{"payload":[],"payloadSize":0}' from endpoint 1 with groupID 0
Zigbee2MQTT:warn  2020-11-30 22:50:36: Received message from unsupported device with Zigbee model 'TS0601' and manufacturer name '_TZE200_fhn3negr'
Zigbee2MQTT:warn  2020-11-30 22:50:36: Please see: https://www.zigbee2mqtt.io/how_tos/how_to_support_new_devices.html.

Above you’ll see that it’s recognising a device called the TS0601, which appears to be a generic name for Tuya compatible devices. This and the manufacturer name are useful information for you to be able to ‘fingerprint’ the device.

Step 5

I started to follow the instructions on this page for adding a Tuya device. However, with their example device configuration I got an error on the tuya.SetTime line, so I commented it out for now

    onEvent: tuya.setTime, // Add this if you are getting no converter for 'commandSetTimeRequest'
ReferenceError: tuya is not defined

This allowed the Zigbee2MQTT plugin to finally start up with my custom configuration and start giving me the debug info I need to follow the instructions for setting up a new Tuya device

Failed Attempt #3

Step 1 (read Step 2 first)

Install Portainer according to these instructions (first time I ran the command it didn’t work, tried again, and it worked…)]

Once installed, navigate to http://YOURIP:9000 to load up the Portainer interface

Step 2

Find my Zigbee2mqtt docker container ‘data’ directory by browsing through my portainer Containers, and to Zigbee2MQTT. Mine was located at /usr/share/hassio/addons/data/7ad98f9c_zigbee2mqtt. So perhaps you could skip step 1 and try navigating to here directly.

Step 3

Identified the correctly compatible version of a donor ‘devices.js’ file by following the instructions here

Navigated to /usr/share/hassio/addons/data/7ad98f9c_zigbee2mqtt and Ran wget https://raw.githubusercontent.com/Koenkk/zigbee-herdsman-converters/c1593eac133130d54160ab46aa6a8486d5cb987b/devices.js

to copy the devices.js file in to my data directory. Gave up here – this didn’t do what I expected, and then after more researching, found it was a bug in Zigbee2MQTT – see instructions above

Leave a Reply

Your email address will not be published. Required fields are marked *