zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

Scene id 0 invalid

Open markchalloner opened this issue 1 year ago • 9 comments

What happened?

When trying to add a scene to a group or device (e.g. Philips Hue bulb with id 0 (e.g. for a scene capable switch to use like the Philips Hue Dimmer V2) the following error is displayed and the scene not added:

Publish 'set' 'scene_store' to 'Test' failed: 'Error: ID must be at least 1'

Workaround was to downgrade to 1.36.0.

Zigbee2MQTT version 1.36.1 commit: unknown Coordinator type zStack3x0 Coordinator revision 20230507 Frontend version 0.6.161 zigbee_herdsman_converters_version 19.11.2 zigbee_herdsman_version 0.40.3

What did you expect to happen?

No error message displayed and the scene dded to the group.

How to reproduce it (minimal and precise)

In any group create a scene id 0

Zigbee2MQTT version

1.36.1

Adapter firmware version

20230507

Adapter

SLZB-06

Setup

Add-on to Home Assistant OS in ProxMox

Debug log

No response

markchalloner avatar Apr 16 '24 19:04 markchalloner

Why would you add scene to a dimmer? They should be added to the bulbs.

malaakso avatar Apr 17 '24 08:04 malaakso

The scene is added to the group for use by a scene capable switch such as the Philips Hue Dimmer V2

markchalloner avatar Apr 17 '24 10:04 markchalloner

Just tested and this is also an issue adding a scene directly to a bulb too.

markchalloner avatar Apr 17 '24 10:04 markchalloner

Both scene and group ID 0 are not allowed, please pick another number.

Koenkk avatar Apr 17 '24 17:04 Koenkk

@Koenkk thanks.

To be clear this bug report is only regarding scene ids not group ids, I've updated the title and added a screenshot below:

image

Is there a reason for disallowing scene id 0?

As far as I can tell from the Zigbee cluster spec under section 3.7.2.3 Scene Table (page 144 in the pdf), a scene id of 0 seems to be valid:

Scene ID | uint8 0x00 to 0xff (see 3.7.2.3.2) | The identifier, unique within this group, which is used to identify this scene.

Disallowing scene id 0 means the Philips Hue Dimmer V2 Hue button which send alternating recalls with scene id 0 and 1 can't be fully bound and unfortunately the scene ids sent are hard-coded in the firmware:

2024-04-17 21:13:12Received Zigbee message from 'Landing Light Dimmer', type 'commandRecall', cluster 'genScenes', data '{"groupid":53372,"sceneid":0}' from endpoint 1 with groupID 53372
2024-04-17 21:13:13Received Zigbee message from 'Landing Light Dimmer', type 'commandRecall', cluster 'genScenes', data '{"groupid":53372,"sceneid":1}' from endpoint 1 with groupID 53372

Cheers

markchalloner avatar Apr 17 '24 20:04 markchalloner

@Nerivec from what I remember this was for the Ember adapter, but reading the spec 0x00 should be valid.

Koenkk avatar Apr 18 '24 20:04 Koenkk

I found this while hunting for a bug related to Ember, but it has no relation. It's ZCL spec. ID zero for groups and scenes are of course valid, but reserved for the global scene.

3.7.2.4.1 Generic Usage Notes Scene identifier 0x00, along with group identifier 0x0000, is reserved for the global scene used by the OnOff cluster.

ZCL spec R8 A few more references can be found throughout the spec by searching for global scene.

Now, it's not very detailed as to how it should be reserved. Could be a global requirement, or they could have meant just for scene ID zero to not be used in conjunction with group ID zero (as in, scene ID zero can be used with any group ID that is NOT zero)... Left to interpretation...

Will have to be careful as to what a change here could potentially break. Ikea seems to be using this scheme and I suspect was the cause for some weird issues people reported with the brand in the past. i.e. Any change should not only be tested against that Philips device, but also against several Ikea devices.

Nerivec avatar Apr 18 '24 21:04 Nerivec

It looks like https://github.com/Koenkk/zigbee-herdsman-converters/pull/7185 is the reason this error gets thrown, and that was first included in Z2M version 1.36.1. The PR doesn't explain why the change was made though - was there a specific problem this was supposed to fix?

jaydeethree avatar May 16 '24 23:05 jaydeethree

@Nerivec

Will have to be careful as to what a change here could potentially break. Ikea seems to be using this scheme and I suspect was the cause for some weird issues people reported with the brand in the past. i.e. Any change should not only be tested against that Philips device, but also against several Ikea devices.

Do you have any links to the issues you suspect might be caused by this so I can do some reading up?

Happy to help with testing, I have a few different IKEA bulbs and remotes too.

Thanks

markchalloner avatar May 17 '24 06:05 markchalloner

Thank you @Nerivec I tested it on 1.38.0 and setting scene 0 for a grous works fine. Appreciate the fix!

markchalloner avatar Jun 08 '24 09:06 markchalloner

@markchalloner Have you managed to set scene 0 for single bulb/lamp or group? Trying to make Hue button working on my Hue Dimmer v2 which is bound to Philips Enrave lamp. I'm getting: Publish 'set' 'scene_store' to 'Living Room Left Ceiling Light' failed: 'Error: Scene ID 0 cannot be used with group ID 0 (reserved).' which is not a surprise given that the code states: const groupid = isGroup ? entity.groupID : (value.group_id != undefined ? value.group_id : 0); meaning for a single bulb/lamp groupId will be always 0 and therefore: if (groupid === 0 && sceneid === 0) { will be always true when setting Scene 0 for a single bulb/lamp @Nerivec is it expected outcome?

kklepacz avatar Jun 13 '24 19:06 kklepacz

Indeed. Zigbee specification reserves the use of scene ID 0 with group ID 0 (it's used for the global scene mechanism). See https://github.com/Koenkk/zigbee2mqtt/issues/22231#issuecomment-2065316124

@Koenkk Probably the fallback shouldn't be zero for group IDs to avoid this kind of trouble? Not sure what ramifications changing this might have though.

Nerivec avatar Jun 13 '24 19:06 Nerivec

Can you try to pass the group ID? add group_id: 1 to the payload, although I'm not sure exactly what the behaviour will be:

Screenshot 2024-06-13 at 21 38 28

Koenkk avatar Jun 13 '24 19:06 Koenkk