Hassio-zigbee2mqtt: Enhancement idea: allow other custom files in addition to devices.js

Created on 27 Dec 2019  路  6Comments  路  Source: danielwelch/hassio-zigbee2mqtt

So I just got some EcoSmart bulbs and remotes that are just now being added to z2m. I downloaded the latest devices.js from Koenkk but I also need to change to get it to work correctly. Would it be possible to have the addon load the fromZigbee.js and toZigbee.js files from the data_path in addition to the devices.js?

Thanks

/app/node_modules/zigbee-herdsman-converters/devices.js
/app/node_modules/zigbee-herdsman-converters/converters/fromZigbee.js
/app/node_modules/zigbee-herdsman-converters/converters/toZigbee.js
/app/lib/extension/homeassistant.js
stale

All 6 comments

Yeah.

It seems like we could just edit run.sh to add in moving the to/from and homeassistant files just like it moves the devices.js file:

if [[ ! -z "$ZIGBEE_SHEPHERD_DEVICES" ]]; then
    echo "[Info] Searching for custom devices file in zigbee2mqtt data path..."
    if [[ -f "$DATA_PATH"/devices.js ]]; then
        cp -f "$DATA_PATH"/devices.js ./node_modules/zigbee-herdsman-converters/devices.js

       cp -f "$DATA_PATH"/fromZigbee.js ./node_modules/zigbee-herdsman-converters/converters/fromZigbee.js
       cp -f "$DATA_PATH"/toZigbee.js ./node_modules/zigbee-herdsman-converters/converters/toZigbee.js

    else
        echo "[Error] File $DATA_PATH/devices.js not found! Starting with default devices.js"
    fi
fi

Is this a bad idea? Will it work? How do I do this? No idea.

@backcountrymountains yep, something like that will work. I'd just modify to check for the existence of fromZigbee.js and toZigbee.js, and handle if they don't exist. We could also expand to include homeassistant.js and utils.js to take care of #194 as well. Feel free to make a pull request, or else I'll get to it when I can.

It would be very cool to have something like gitpod or VisualStudioOnline integration to help with the debugging of new devices.

... maybe it should be logged as another issue here.

I attempted a pull request. No idea.

Also, it's possible to modify the files in the docker container:
Instructions from zigbee2mqtt.io

I downloaded the files from zigbee-herdsman-converters, made backups, and overwrote the files in the addon. Then I restarted it using docker restart. Seemed to work okay.

docker ps

docker exec -it 645d5cf82628 bash

cp fromZigbee.js  /share/zigbee2mqtt/fromZigbee.js.bak
cp toZigbee.js  /share/zigbee2mqtt/toZigbee.js.bak
cp /share/zigbee2mqtt/converters/toZigbee.js .
cp /share/zigbee2mqtt/converters/fromZigbee.js .
cp /share/zigbee2mqtt/converters/utils.js .
ls -alu

cp homeassistant.js /share/zigbee2mqtt/homeassistant.js.bak
cp /share/zigbee2mqtt/homeassistant.js .

ls -alu

exit

docker restart 645d5cf82628

"Be aware that changes are not persistent, any changes that recreate the Docker container will result in the changes being lost, so make sure your modifications are provided back to the project for out-of-the-box support. Also using the Restart button from the web interface will remove your changes."

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ciotlosm picture ciotlosm  路  6Comments

highground88 picture highground88  路  7Comments

Claypaenguin picture Claypaenguin  路  3Comments

0xygen8 picture 0xygen8  路  6Comments

wolverinevn picture wolverinevn  路  10Comments