Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
11.77k stars 1.64k forks source link

Name subsitution for the multiEndpoint #4153

Closed manju-rn closed 4 years ago

manju-rn commented 4 years ago

Bug Report

What happened

Wanted to get some clarification on the endpoint names in the multiendpoint setup. If I have 2 endpoints and I name them as left, right, top or bottom, they just work fine when I call them by passing Mqtt message zigbee2mqtt//left/set/state with relevant raw payload 'on or off'. I thought the endpoint name does not matter, however, if I change it to say "leftw" or "rightw" It does not work. So where is the mapping kept that only top, bottom, left right works? meta: {multiEndpoint: true, configureKey: 1}, endpoint: (device) => { return {'left': 1, 'right': 2};

This does not work meta: {multiEndpoint: true, configureKey: 1}, endpoint: (device) => { return {'leftw': 1, 'rightw': 2};

What did you expect to happen

If I have given the endpoint name as leftw or rightw, I was expecting that the MQTT message like zigbee2mqtt//leftw/set/state with payload on or off or toggle should work. It rather returns zigbee2mqtt:error 2020-08-21 23:33:15: Entity '/leftw' is unknown

So I was wondering if there is some mapping that is done against the left, right, top, bottom? If yes, how can we edit that to include custom names for the multiendpoints?

How to reproduce it (minimal and precise)

Debug Info

Zigbee2MQTT version: 1.14 Adapter hardware: CC2531, CC2530, CC26X2R1 or CC1352P-2: CC2531- Co-ordinator; CC1352p-2 - end device (custom coded through code composer studio of TI Adapter firmware version:

manju-rn commented 4 years ago

The above is resolved.

  1. The endpoint names are maintained in https://github.com/Koenkk/zigbee2mqtt/tree/master/lib/util/util.js

const endpointNames = [ 'left', 'right', 'center', 'bottom_left', 'bottom_right', 'default', 'top_left', 'top_right', 'white', 'rgb', 'cct', 'system', 'top', 'bottom', 'center_left', 'center_right', 'ep1', 'ep2', 'row_1', 'row_2', 'row_3', 'row_4', 'relay', 'l1', 'l2', 'l3', 'l4', 'l5', 'l6', 'l7', 'l8', 'button_1', 'button_2', 'button_3', 'button_4', 'button_5', 'button_6', 'button_7', 'button_8', 'button_9', 'button_10', 'button_11', 'button_12', 'button_13', 'button_14', 'button_15', 'button_16', 'button_17', 'button_18', 'button_19', 'button_20', ];

  1. You could add additional names such as fan_on, fan_off, // Just make sure there is a comma , at the end

If you are using a docker, you could follow the below steps

  1. In a seperate dir, clone the z2m from github. git clone https://github.com/Koenkk/zigbee2mqtt
  2. Modify the utils.js under <path_to_Local Dir where clone is made>/zigbee2mqtt/lib/util
  3. Expose this lib as a volume when starting the docker. For e.g if you are running the docker via command, provide additional volume parameter -v <path_to_Local Dir where clone is made>/zigbee2mqtt/lib:/app/lib
  4. You could double check the utils.js by going inside the docker container at runtime docker exec -it <process_name> /bin/sh and check the file cat /app/lib/util/utils.js