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

I had zigbee2mqtt running in Docker which logged quite nicely to the Docker log:

zigbee2mqtt | zigbee2mqtt:info 2020-07-23 14:57:51: Starting zigbee2mqtt version 1.13.0 (commit #55e6283)

Now I have moved it to a Pi and I’m running it from systemd directly. systemd is capturing the console output to the journal and syslog but it contains colour sequences which are not rendering properly. Also I don’t need the time repeated as syslog records that.

Jul 25 04:07:30 zigbeepi bash[1225]: #033[32mzigbee2mqtt:info #033[39m 2020-07-25 04:07:30: Starting zigbee2mqtt version 1.14.2 (commit #faaf3e4)

I tried configuring zigbee2mqtt to log to syslog itself, instead of console, which works but it seems to send JSON to the syslog instead of plain text:

Jul 25 05:05:05 localhost zigbee2mqtt[1819]: {"message":"Starting zigbee-herdsman...","level":"info"}

Is there some way to configure it to output plain text (no JSON, no colours), either to syslog or to the console?

For your permit_join, use this :

# Switch for enabling joining
switch:
  - platform: mqtt
    name: "Zigbee2mqtt Main join"
    state_topic: "zigbee2mqtt/bridge/config/permit_join"
    command_topic: "zigbee2mqtt/bridge/config/permit_join"
    payload_on: "true"
    payload_off: "false"

automation:

  # Automation to start timer when enable join is turned on
  - id: zigbee_join_enabled
    alias: Zigbee Join Enabled
    trigger:
      platform: state
      entity_id: switch.zigbee2mqtt_main_join
      to: "on"
    action:
      service: timer.start
      entity_id: timer.zigbee_permit_join
  # Automation to stop timer when switch turned off and turn off switch when timer finished
  - id: zigbee_join_disabled
    alias: Zigbee Join Disabled
    trigger:
      - platform: event
        event_type: timer.finished
        event_data:
          entity_id: timer.zigbee_permit_join
      - platform: state
        entity_id: switch.zigbee2mqtt_main_join
        to: "off"
    action:
      - service: timer.cancel
        data:
          entity_id: timer.zigbee_permit_join
      - service: switch.turn_off
        entity_id: switch.zigbee2mqtt_main_join

1 Like

Can some admin tag this thread zigbee2mqtt so it is easier to find?

For your input_select to sync :

sensor:
  - platform: mqtt
    name: ZigBee Log Level
    state_topic: "zigbee2mqtt/bridge/config"
    value_template: "{{  value_json.log_level }}"
# Input select for Zigbee2mqtt debug level
input_select:
  zigbee2mqtt_log_level:
    name: Zigbee2mqtt Log Level
    options:
      - debug
      - info
      - warn
      - error
    initial: info
    icon: mdi:format-list-bulleted
automation:
  # Automation for sending MQTT message on input select change
  - alias: Zigbee2mqtt Log Level
    initial_state: "on"
    trigger:
      platform: state
      entity_id: input_select.zigbee2mqtt_log_level
    action:
      - service: mqtt.publish
        data:
          payload_template: "{{ states('input_select.zigbee2mqtt_log_level') }}"
          topic: zigbee2mqtt/bridge/config/log_level
  # Automation for sending MQTT message on input select change
  - id: '1595654450786'
    alias: Sync Zigbee log level input_select
    description: Sync Zigbee log level input_select
    mode: single  
    trigger:
    - entity_id: sensor.zigbee_log_level
      platform: state
    condition: []
    action:
    - service: automation.turn_off
      entity_id: automation.zigbee2mqtt_log_level  
    - service: input_select.select_option
      data_template:
        option: '{{states("sensor.zigbee_log_level")}}'
        entity_id: input_select.zigbee2mqtt_log_level
    - service: automation.turn_on
      entity_id: automation.zigbee2mqtt_log_level  

@francisp, that worked like a charm!

I changed the input_boolean to a template switch, tweak my automations and the switch definition you provided and the sync between the UI and zigbee2mqtt is perfect!

Here is the final configuration for those interested. Now, I’ll try the log, but I believe it will work too :slight_smile:

sensors:
  - platform: mqtt
    name: podeentrarzigbee
    state_topic: "zigbee2mqtt/bridge/config"
    value_template: "{{ value_json.permit_join }}"

timer:
  zigbee_permit_join:
    name: Temporizador para ingresso ZigBee
    duration: 60

switch:
  - platform: template
    switches:
      permitir_o_ingresso_na_rede_zigbee:
        friendly_name: "Permitir o ingresso na rede ZigBee"
        value_template: "{{ is_state('sensor.podeentrarzigbee', 'True') }}"
        turn_on:
          service: mqtt.publish
          data:
            payload: 'true'
            topic: zigbee2mqtt/bridge/config/permit_join
        turn_off:
          service: mqtt.publish
          data:
            payload: 'false'
            topic: zigbee2mqtt/bridge/config/permit_join

automation:
  - id: '1595186210127'
    alias: ZigBee -- permitir ingresso na rede
    description: ''
    trigger:
    - entity_id: switch.permitir_o_ingresso_na_rede_zigbee
      platform: state
      to: 'on'
    condition: []
    action:
    - data: {}
      entity_id: timer.zigbee_permit_join
      service: timer.start
  - id: '1595186547491'
    alias: ZigBee -- finalizar permissão de ingresso na rede
    description: ''
    trigger:
    - event_data:
        entity_id: timer.zigbee_permit_join
      event_type: timer.finished
      platform: event
    - entity_id: switch.permitir_o_ingresso_na_rede_zigbee
      platform: state
      to: 'off'
    condition: []
    action:
    - data: {}
      entity_id: timer.zigbee_permit_join
      service: timer.cancel
    - data: {}
      entity_id: switch.permitir_o_ingresso_na_rede_zigbee
      service: switch.turn_off
1 Like

Nailed it! Thanks a lot!

Thanks @Koenkk for this great work. I am in the middle of trying to add a new device and need some help. I think I have followed all the info here: https://www.zigbee2mqtt.io/how_tos/how_to_support_new_devices.html#hassio-addon and I have the device working but only one way. The device I am adding is here: https://www.amazon.com.au/Approved-Smart-ZigBee-Switch-Automation/dp/B08D7BRS2Q/ref=pd_rhf_sc_p_img_3

I have modelled it on the existing device here: https://www.zigbee2mqtt.io/devices/HGZB-44.html as this device presents as four different switches.

Thus my devices.js entry is here:

    {
        zigbeeModel: ['LXN56-1S27LX1.2'],
        model: 'NUE-ZBFLB',
        vendor: 'Nue / 3A',
        description: 'Smart Fan Light Switch',
        supports: 'on/off',
        fromZigbee: [fz.on_off],
        toZigbee: [tz.on_off],
        endpoint: (device) => {
                return {'light': 1, 'fan_high': 2, 'fan_med': 3, 'fan_low': 4};
            },
            meta: {configureKey: 1, multiEndpoint: true},
            configure: async (device, coordinatorEndpoint) => {
                await bind(device.getEndpoint(1), coordinatorEndpoint, ['genOnOff']);
                await bind(device.getEndpoint(2), coordinatorEndpoint, ['genOnOff']);
                await bind(device.getEndpoint(3), coordinatorEndpoint, ['genOnOff']);
                await bind(device.getEndpoint(4), coordinatorEndpoint, ['genOnOff']);
                }
    },

My homeassistant.js entry is:

    'NUE-ZBFLB': [
        switchEndpoint('light'), switchEndpoint('fan_high'), switchEndpoint('fan_med'),
        switchEndpoint('fan_low'),
    ],

I now see four entities in HA:

 - entity: switch.hannah_light_fan_switch_switch_light
 - entity: switch.hannah_light_fan_switch_switch_fan_low
 - entity: switch.hannah_light_fan_switch_switch_fan_med
 - entity: switch.hannah_light_fan_switch_switch_fan_high

The problem is when I press a button on the wall HA correctly changes state but when I change one of the switches in HA nothing happens and I see an error in the MQTT logs.

Zigbee2MQTT:debug 2020-09-01 16:03:51: Received Zigbee message from 'Hannah Light Fan Switch', type 'attributeReport', cluster 'genOnOff', data '{"onOff":1}' from endpoint 1 with groupID 0
Zigbee2MQTT:info  2020-09-01 16:03:51: MQTT publish: topic 'zigbee2mqtt/Hannah Light Fan Switch', payload '{"state_light":"ON","linkquality":39,"state_fan_high":"OFF","state_fan_med":"OFF","state_fan_low":"OFF"}'
Zigbee2MQTT:debug 2020-09-01 16:03:51: Received Zigbee message from 'Hannah Light Fan Switch', type 'attributeReport', cluster 'genOnOff', data '{"onOff":1}' from endpoint 1 with groupID 0
Zigbee2MQTT:info  2020-09-01 16:03:51: MQTT publish: topic 'zigbee2mqtt/Hannah Light Fan Switch', payload '{"state_light":"ON","linkquality":39,"state_fan_high":"OFF","state_fan_med":"OFF","state_fan_low":"OFF"}'
Zigbee2MQTT:debug 2020-09-01 16:04:03: Received Zigbee message from 'Hannah Light Fan Switch', type 'attributeReport', cluster 'genOnOff', data '{"onOff":0}' from endpoint 1 with groupID 0
Zigbee2MQTT:info  2020-09-01 16:04:03: MQTT publish: topic 'zigbee2mqtt/Hannah Light Fan Switch', payload '{"state_light":"OFF","linkquality":42,"state_fan_high":"OFF","state_fan_med":"OFF","state_fan_low":"OFF"}'
Zigbee2MQTT:debug 2020-09-01 16:04:03: Received Zigbee message from 'Hannah Light Fan Switch', type 'attributeReport', cluster 'genOnOff', data '{"onOff":0}' from endpoint 1 with groupID 0
Zigbee2MQTT:info  2020-09-01 16:04:03: MQTT publish: topic 'zigbee2mqtt/Hannah Light Fan Switch', payload '{"state_light":"OFF","linkquality":39,"state_fan_high":"OFF","state_fan_med":"OFF","state_fan_low":"OFF"}'
Zigbee2MQTT:debug 2020-09-01 16:04:44: Received MQTT message on 'zigbee2mqtt/Hannah Light Fan Switch/light/set' with data 'ON'
Zigbee2MQTT:info  2020-09-01 16:04:44: MQTT publish: topic 'zigbee2mqtt/bridge/log', payload '{"type":"entity_not_found","message":{"friendly_name":"Hannah Light Fan Switch/light"}}'
Zigbee2MQTT:error 2020-09-01 16:04:44: Entity 'Hannah Light Fan Switch/light' is unknown

Can anyone shed any light on what I am doing wrong / what else I need to do to get this working?

Version 1.15.0 just released

2 Likes

To me, it seems that HA update 0.115 has broke something on Zigbee2Mqtt. The network is crashing multiple times per week suddenly after the update and setting “permit_join: True” seems to crash it too quite often. I updated zigbee2mqtt to 1.15.0 but it did not help. The problem seems to be reported on Github already though it is not only Hassio problem.

Waiting my CC2652 and hopefully that helps with the problem. Only thing is that most likely never going to receive the stick as the seller seems to be selling air and not the sticks but that is a different problem :smiley:

Hi, everything is working fine for me. I’m on version 1.14.4 and HA 0.115.2

First of all: thank you for the work you did put in this tool. Worked from the first moment like a charm.

Edit: So ok, I fixed this… Seemed one of my wires wasn’t properly connected :stuck_out_tongue_winking_eye:

Hi guys,

I’ve done a pretty big refactoring for the add-on (see: https://github.com/danielwelch/hassio-zigbee2mqtt/pull/443/files).

I need people that want to test the new version. You can try it by using this repo: https://github.com/zigbee2mqtt/hassio-zigbee2mqtt

You can also join the Zigbee2mqtt Discord for discussions around this.

1 Like

Im experiencing the same problem

As co-incidence would have it, I was trying to help in this thread, and I see you have changed the docs in the new refactor. I am even more confused :slight_smile: In the meantime, can you assist? (or point him to the right discord? Zigbee2mqtt - unsupported device integration

The problem with the docs is that the information was not grouped based on needs. Also the approach using devices.js is not really something that should be supported in the long run now that external_converters are supported.

Hi everyone,

I have the following problem.
Since the new zigbee2mqtt release v1.15.0 the following device ( bridge / info ) appears to me, and I cannot remove it.

Hi everyone,

I have the following problem.
Since the new zigbee2mqtt release v1.15.0 the following device appears to me, and I cannot remove it.
What could that be?

I didn’t have that before
What could that be?




Try using the built-in UI (click Show in sidebar) and see if that still shows that “device”.
Also make sure you have

experimental:
  new_api: true

Could be just an MQTT topic that you can remove with MQTT explorer

the (bridge / info) is no longer displayed.
And the coordinator is no longer displayed either.

And linkquality is zero.
Some things are not right there.


Coordinator details should be found under settings /raw but I have no idea why the LQI is 0. Maybe try and check the mqtt message that it’s using.