matterbridge-zigbee2mqtt icon indicating copy to clipboard operation
matterbridge-zigbee2mqtt copied to clipboard

feat: added option to specify unique postfix

Open L2jLiga opened this issue 1 year ago • 4 comments

Currently plugin uses hostname as unique postfix, which can cause problems, for example:

  • When moving matterbridge to another machine, then all Z2M entities got duplicated because they will have new serial number because of hostname change
  • When deployed in Kubernetes with host network, then pod receives real machine hostname instead of pod name, this lead to the same problem - when matterbridge got deployed on another node you will get duplicates

L2jLiga avatar Aug 16 '24 00:08 L2jLiga

Hi, thanks for your interest and your PR. I'm currently on holiday. I will check it soon but if I'm right you propose to make optional the hostname postfix:

  • that is coming from my homebridge plugin that has the eve history on all devices where you need it for the Eve app;
  • on matterbridge I guess there is no reason to keep it, so I agree with you;
  • we need a way that doesn't cause to all users to loose the room/automations configuration on the controller already paired.

Luligu avatar Aug 20 '24 05:08 Luligu

Hi, no problem, have a nice rest :)

My proposal is about making this option configurable

we need a way that doesn't cause to all users to loose the room/automations configuration on the controller already paired.

If my understanding correct, this postfix will be automatically filled with hostname, so it shouldn't cause any breakage, check this: https://github.com/Luligu/matterbridge-zigbee2mqtt/pull/56/files#diff-8260ea6250f2a0f124153ffb1bddae058191ea4e8baf1de5d4746083f6c44d81R96

May be it would be better to replace this with nullish coalescing, so this way hostname could be omitted at all

L2jLiga avatar Aug 20 '24 12:08 L2jLiga

Hi, so the PR are only against the dev. If you want we can go ahead but add a kind of postfixHostname to the schema file like boolean. In platform we need to be sure that even if the user doesn't update the config, we have a default of true so unless the user does it on purpose there is no change in the MatterbridgeDevice. In BridgedBaseDevice we have ZigbeeEntity that has ZigbeePlatform so no need to change the classes constructors, you have the config there.

Luligu avatar Aug 22 '24 06:08 Luligu

so the PR are only against the dev.

Done

add a kind of postfixHostname to the schema file like boolean.

sounds good to me, should be enough for my use-cases

In platform we need to be sure that even if the user doesn't update the config, we have a default of true so unless the user does it on purpose there is no change in the MatterbridgeDevice.

Totally agree, true should be by default to avoid breakage

In BridgedBaseDevice we have ZigbeeEntity that has ZigbeePlatform so no need to change the classes constructors, you have the config there.

My bad, fixed =)

L2jLiga avatar Aug 22 '24 09:08 L2jLiga

Hi, thanks you so much. I apologize for the late answer, but I'm working on a project that is urgent. Everything seems more then perfect. Tomorrow I will just make a few test but I'm sure you already did. Users of controllers that remove devices when matterbridge changes the uniqueId (e.g. AppleHome and GoogleHome) will kill us if they loose names, rooms and automations...

Luligu avatar Aug 28 '24 21:08 Luligu