-
Notifications
You must be signed in to change notification settings - Fork 356
Hue reset by serial number #1556
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
Conversation
|
The sendZcl function should use an extra arg instead of duplicating the whole function (like others do to flip "response" requirement). Custom clusters should not be added to ZH anymore (in ZHC instead), problem is, this is not triggered by converters... but the custom cluster overrides the Touchlink one, so, it's conflict-prone... Needs testing on adapters that would/should support this, and also with other devices that would require the real touchlink cluster and could conflict with this one (I'm assuming some Philips -or Philips code using- devices should not use that custom cluster). Overall, we want to avoid ZH being specific manufacturer-wise, but this feature is completely the opposite (and restricted to few devices too)... Not sure how to handle it for this case though 🤷 @chrivers any insights on the issue? |
d8ad81a to
737b1da
Compare
|
The cluster conflict would be a problem if some Philips devices (or devices using the same manuf code) do not support the custom cluster. It would fail reading frames properly for cmd 0x00. I'm not sure if that manuf code is common (non-Philips devices would certainly fail, since this is custom Philips firmware only), other manuf aren't supposed to use assigned codes, but.... So, long shot, but possible... The fact we'd need custom ZH-layer support, custom Z2M-layer support & custom frontend-layer support is... 😰 |
|
Hmm. I would think this should be pretty much equivalent to the normal hue bridge sending this message, no? They just have a text field for serial number in the app and it'll seemingly do the same thing. Here's an article with some screenshots: https://www.trustedreviews.com/how-to/how-to-reset-philips-hue-bulbs-with-and-without-a-bridge-4145209 I don't know a ton about zigbee, so maybe I'm totally off-base here, but I'd think an unknown manufacturer-specific cluster broadcast shouldn't break other devices assuming everyone is conforming to the spec... right?
Is there a way to do this without adding to zigbee-herdsman or zigbee2mqtt? In my experience, hue bulbs are pretty temperamental. They way I intend to use this is only via the mqtt interface. Is it a matter of policy to support every feature in the frontend? |
|
First of all, thanks for the implementation! @Nerivec is right on the fact that we want to prevent manufacturer specific stuff in zigbee-herdsman as much as possible. It would be the nicest if this can be completely implemented in zigbee-herdsman-converters (as this is were we put all the manu specific stuff). My initial thoughts
|
|
I think I get your meaning. Does this seem like a good starting point for a new There seems to be a need for an This would require some changes on the zigbee-herdsman side to expose this functionality publicly, though, since right now I think this is going to be a bigger change, so I want to make sure I run the architecture decisions by you first lol. |
|
Everything in ZHC is going to require a device/endpoint/group, this would require a major refactor I think. What if we implement a interface RawPayload {
ieeeAddress?: string;
networkAddress?: number;
groupId?: number;
dstEndpoint?: number;
srcEndpoint?: number; // defaults to `ZSpec.HA_ENDPOINT`
interPan?: boolean; // defaults to false
profileId?: number; // defaults to `ZSpec.HA_PROFILE_ID`
clusterKey?: number | string;
frame: {}; // omitted for brevity, contains the stuff needed for `Zcl.Frame.create`
disableResponse?: boolean; // defaults to false
timeout?: number; // defaults to 10000
}and passes all these directly to ZH Controller
Just a quick overview, need to refine the payload, call conditions & more, and a good payload validation on Z2M side. The payload for a feature such as this PR could then be documented like others are, in the Z2M docs relevant pages. Bonus: this could be mighty useful beyond this feature too, with the obvious being debugging purposes. |
|
This idea occurred to me too when we were talking earlier... I don't love the idea of having the logic and commands being totally at the whims of the consumer though. In this case, for example, the consumer would need to sweep the channels themselves and send a message to each. Additionally, kicking us back out of InterPAN mode between each message could cause some weird behavior if an interview for a new device happens before we send the next channel's message. We'd also need to add some extra handling for data types which can't be natively serialized as json like I also don't love doing it with ZHC converters either though... ZHC could have a separate "detached converters" export with some manufacturer specific commands which take in a |
|
The // publish whole in `bridge/definitions`
export const RAW_PAYLOADS: Record<string, RawPayload> = {
xyz_trigger_custom_behavior: {}, // omitted for brevity
// ...
}
// publish keys in `bridge/definitions`
export const RAW_ACTIONS: Record<string, () => Promise<void>> = {
hue_serial_reset: (sendRaw: (args: RawPayload) => Promise<void>, args: Record<string, unknown>) => {
// trigger more advanced logic
}
// ...
}And we can trigger from Z2M in bridge extension using something like import {RAW_ACTIONS} from "zigbee-herdsman-converters";
function raw(message: string | KeyValue): Promise<Zigbee2MQTTResponse<"bridge/response/raw">> {
// message: {action?: string; args?: Record<string, unknown>, payload?: Record<string, RawPayload>};
if (message.action) {
// validation
const func = RAW_ACTIONS[message.action];
if (func) {
return func(this.zigbee.sendRaw.bind(this.zigbee), message.args ?? {});
}
} else if (message.payload) {
// validation
return this.zigbee.sendRaw(message.payload);
}
}Again, just a quick write-up, needs more refining. |
|
For now, I can add just raw actions (and a hue reset action as a "patient zero" of sorts) (no custom/predefined payloads, etc. Those can be added later if you want them) to Z2M, ZH, and ZHC. Reasonable? To expand a little more, I was thinking:
Only other thing I can think of is how to register the cluster. I could just create it in ZHC at the call-site (i.e. in the Thanks! |
|
@Nerivec I like it! |
|
@Mstrodl I'll work out a base, we can refine what's needed as we go, I'll ping you to make sure implementing this particular custom will fit nicely, we'll use it as a template (I don't have any Hue device to test this with, so you'll have to 😉). |


See: Koenkk/zigbee2mqtt#3492
I couldn't find any docs for these commands, but I worked off the excellent pcap files and analysis from @itavero in that issue. I'm also not really super well-versed in zigbee stuff, so maybe this is all totally the wrong to do this. Advice appreciated :)
I have tested this with a Philips Hue LED strip and it seems to work pretty well using an
emberSiLabs MGM12P-based device running a fork of zigbee2mqtt with this feature added. The changes for other adapters are untested because I don't have any of them, but they seem like they should probably work.Basically, we sweep every channel and broadcast this reset command, and if a device finds its serial number in that command, it will leave the network it was in and attempt to join the network matching the EPAN ID in the command. As a result, there's not a great way to know if a device actually received and acted on the message or not other than seeing it attempt to join the network on the normal channel some time later. If anyone has better ideas on how to do this, I'm all ears.
Let me know if the
sendZclFrameInterPANBroadcastWithoutReplychanges should be their own PR or somehow combined withsendZclFrameInterPANBroadcast(perhaps a timeout ofnullcould make it not wait for a reply?)