✏️ Fix duplicate endpoints in Z2M state names#156
✏️ Fix duplicate endpoints in Z2M state names#156andrei-lazarov wants to merge 2 commits intoromasku:mainfrom
Conversation
|
I like this change, thank you! However, I think it could be a breaking change, since I’m not sure HA entities will migrate to the new names. I’m almost certain automations will break, and possibly even just exposing the entity on the dashboard. Could you please check this, and if that’s the case, can you please add the corresponding changelog entry? |
|
Right... not sure how to do it though. This is only a converter update so not related to the firmware changelog. |
ef1d376 to
d7cdd82
Compare
d7cdd82 to
e30f9c5
Compare
|
If you want, it might be possible to define a new class https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/src/lib/exposes.ts#L115 that overrides the withEndpoint function to be different. Totally untested, but something like this might work: class CustomSwitch extends exposes.Switch {
withEndpoint(endpointName: string) {
super.withEndpoint(endopintName);
if (this.property) {
this.property = `${this.endpoint}_${this.property}`;
}
}
}buuuuut wiring that up might not be straight forward. Chasing it down further. I think it's the calls to We might be able to do something like this: switchAction: (name, endpointName) => {
let e = enumLookup({
name,
endpointName,
lookup: { on_off: 0, off_on: 1, toggle_simple: 2, toggle_smart_sync: 3, toggle_smart_opposite: 4 },
cluster: "genOnOffSwitchCfg",
attribute: "switchActions", // Enum8
description: `Select how switch should work:
- on_off: When switch physically moved to position 1 it always generates ON command, and when moved to position 2 it generates OFF command
- off_on: Same as on_off, but positions are swapped
- toggle_simple: Any press of physical switch will TOGGLE the relay and send TOGGLE command to binds
- toggle_smart_sync: Any press of physical switch will TOGGLE the relay and send corresponding ON/OFF command to keep binds in sync with relay
- toggle_smart_opposite: Any press of physical switch: TOGGLE the relay and send corresponding ON/OFF command to keep binds in the state opposite to the relay`,
});
e.exposes[0].withProperty(`something_custom_${endpointName}`);
return e
},(And I've reached what I can reasonably to from just reading the code. I have no access to the z2m or zigbee network right now to try further) |



@ashb pointed out that the states look ugly in HA (or in Z2M ➡ Device ➡ State).
Notice how
switch_leftis duplicated:I would prefer it at the front so the states would be grouped by switch if sorted alphabetically. It should be:
But it looks like Z2M automatically appends the endpoint in
exposes.ts(I guess?):So this is the best I can do:
I edited the converters template for the new format.
Unfortunately, after updating the converters, Z2M still shows the old (now unresponsive) states, along with the new ones.
You can get rid of the old entries by removing them from the state history (
zigbee2mqtt/state.json), or by deleting the file altogether and letting Z2M rebuild it.I don't know if Z2M ever clears history organically.