Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting zboss adapter to always use LUMI manufacturer code #1331

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

captainlettuce
Copy link

The fix for this seems to have been to set the manufacturer code to match the incoming code for the specific vendor.

Since the zboss library doesn't set the manufacturerCode anywhere i assume it's fine to just set it globally?

According to the Nordic documentaation for ZBOSS the NCP code on the micro-controller transparently handles the node_desc messages without interaction from the host, so a case-by-case implementation would require custom firmware.

For now i think that just setting the ManufacturerCode is an okay workaround, yes?

Side-note: Some documentation in zigbee2mqtt on how to override the zigbee-herdsman version would be A+ from a dev-standpoint.

@captainlettuce captainlettuce force-pushed the master branch 2 times, most recently from debea94 to 13b3038 Compare March 2, 2025 18:09
@Nerivec
Copy link
Collaborator

Nerivec commented Mar 2, 2025

The default manuf code would be set in firmware, ZH just doesn't appear to override it (likely not needed).
This could lead to other, hard-to-detect, bugs for other manufacturers. I'd say best to set it when a LUMI device joins and override it back on network close. See example for ember:

if (policyDecision !== EmberJoinDecision.DENY_JOIN) {
const payload: DeviceJoinedPayload = {
networkAddress: newNodeId,
ieeeAddr: newNodeEui64,
};
// set workaround manuf code if necessary, or revert to default if previous joined device required workaround and new one does not
const joinManufCode = WORKAROUND_JOIN_MANUF_IEEE_PREFIX_TO_CODE[newNodeEui64.substring(0, 8)] ?? DEFAULT_MANUFACTURER_CODE;
if (this.manufacturerCode !== joinManufCode) {
await this.queue.execute<void>(async () => {
logger.debug(`[WORKAROUND] Setting coordinator manufacturer code to ${Zcl.ManufacturerCode[joinManufCode]}.`, NS);
await this.ezsp.ezspSetManufacturerCode(joinManufCode);
this.manufacturerCode = joinManufCode;
this.emit('deviceJoined', payload);
});
} else {
this.emit('deviceJoined', payload);
}

if (this.manufacturerCode !== DEFAULT_MANUFACTURER_CODE) {
logger.debug(`[WORKAROUND] Reverting coordinator manufacturer code to default.`, NS);
await this.ezsp.ezspSetManufacturerCode(DEFAULT_MANUFACTURER_CODE);
this.manufacturerCode = DEFAULT_MANUFACTURER_CODE;
}


Side-note

Package linking would be the easiest way.
https://pnpm.io/cli/link
But there are a lot of different setups out there, different approaches...

@Koenkk
Copy link
Owner

Koenkk commented Mar 2, 2025

@kirovilya please take a look

@Nerivec
Copy link
Collaborator

Nerivec commented Mar 8, 2025

I don't think this last commit works.
The code has to be set when a device requests joining, so that when the device requests the coordinator's node descriptor it fakes being a lumi hub (that request is between device<>coordinator, Z2M is not involved, doesn't even see it).
It should be set whenever the coordinator informs Z2M of device joined, and then can be reset later by some other appropriate event.

@captainlettuce captainlettuce changed the title Setting zboss adapter to always use LUMI manufacturer code Draft: Setting zboss adapter to always use LUMI manufacturer code Mar 9, 2025
@captainlettuce
Copy link
Author

captainlettuce commented Mar 9, 2025

@Nerivec you are correct. Thanks for the hints, I'll give it a try.

I pushed the commit to this branch for testing, I'll mark the PR as draft until I can verify the next iteration works.

@Nerivec Nerivec marked this pull request as draft March 9, 2025 12:51
@captainlettuce captainlettuce changed the title Draft: Setting zboss adapter to always use LUMI manufacturer code Setting zboss adapter to always use LUMI manufacturer code Mar 9, 2025
@captainlettuce captainlettuce marked this pull request as ready for review March 9, 2025 13:06
@captainlettuce
Copy link
Author

captainlettuce commented Mar 9, 2025

image
image

Confirmed working and i can still join other devices as well

@Nerivec

@Nerivec
Copy link
Collaborator

Nerivec commented Mar 9, 2025

You'll want to add the secondary IEEE prefix for lumi too.
See https://github.com/Koenkk/zigbee-herdsman/pull/1334/files

I also moved away from using permit join to disable, since it won't trigger automatically anymore (unless explicitly triggered by user), meaning it won't reset in a lot of cases. Any chance you have another event like ember (stack closed) that you can use?

@captainlettuce
Copy link
Author

I added the second manufacturer code as requested.

I also moved away from using permit join to disable, since it won't trigger automatically anymore (unless explicitly triggered by user), meaning it won't reset in a lot of cases. Any chance you have another event like ember (stack closed) that you can use?

I'm not sure how the ember adapter works or how it differs from the zboss stack. From a cursory glance it seems that ZIGBE_NETWORK_CLOSED is when closing the actual network, not a specific device leaving, right?

I looked through the zboss spec and can't find anything similar, the only "events" (called indications in zboss) are for when devices leave, which we can not use since we don't know if we have more Lumi devices that are still connected. (?)

My thinking is that the node descriptor should mainly be requested when joining, and since we reset before allowing join it should not be any problems for currently joined devices if the manufacturer code is stuck as Lumi?

If that is not the case please help me pinning down what actually needs to be done.

@Nerivec
Copy link
Collaborator

Nerivec commented Mar 9, 2025

It should mostly be fine I think. It creates a few edge cases, but hopefully not too problematic. Technically, proper devices should not use the manuf code as a barrier like these crappy Aqara devices... so, that, in itself, should limit the impact. It just creates a state that makes debugging a lot harder in case it is ever a problem.
@kirovilya can help better than me on that front though. I don't know the zboss stack well at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants