Skip to content

Conversation

@MfCrizz
Copy link

@MfCrizz MfCrizz commented Nov 22, 2025

Enhances the AddScene component, allowing scenes to be updated directly instead of requiring them to be deleted first.

  • The action button will change dynamically depending on whether or not a scene already exists:
    • "Add" action: Behavior same as before.
    • "Update" action: When an existing scene ID is selected, the current scene name will be prefilled and the "Update" button will appear. This allows for quicker scene modifications and updates.
  • A confirmation modal will be shown for "update" actions, decreasing the likelihood of unintended modifications.
  • Deleting a single scene will update the state, switching from "Update" to "Add" actions.
  • Deleting all scenes resets the component to its default empty state.
Kooha-2025-11-22-23-11-09.webm

@MfCrizz MfCrizz marked this pull request as ready for review November 22, 2025 22:49
@Nerivec
Copy link
Owner

Nerivec commented Nov 23, 2025

I've been asked this before, but this has consequences on the Zigbee side that need testing, Z2M only ever used this to store new scenes, we don't really know how devices will behave (if they will follow spec, fail, make a mess...). The handling of scenes in the Zigbee spec is a little strange/convoluted, so, that makes it more prone to spec-deviations.
Here's what the spec says on Store Scene command:

The device adds the scene entry into its Scene Table along with all extension field sets corresponding
to the current state of other clusters on the same endpoint on the device and the Transition Time and
Scene Name entries set to 0 and the null string, respectively. If there is already a scene in the Scene
Table with the same Scene ID and Group ID, it SHALL overwrite it, i.e., it SHALL first remove all
information included in the original scene entry except for the Transition Time and Scene Name
entries, which are left unaltered.


Scene stuff definitely needs some love though. We should be able to expand with other commands & co too. This month was bind/report, I guess next month can be scenes 😁

@MfCrizz
Copy link
Author

MfCrizz commented Nov 23, 2025

I knew it couldn't be that easy! :D
How about issuing a "scene delete" command before creating a new scene when the update action is performed?
Happy to help :)

@Nerivec
Copy link
Owner

Nerivec commented Nov 23, 2025

I think we're better off testing the store scene "as update" on a few devices to see how well it's received/processed. The problem with chaining commands is the potential for failure of any command in the chain, and the state weirdness that could ensue.

I was thinking of investigating the whole scene thing a bit further, and seeing if we can improve the overall handling, there are a lot more commands than just store/recall in the spec. Also, scene stuff is currently handled via converters in ZHC, but really, I think it might benefit from a move to ZH (it's spec). Similar to what is currently being done for other stuff like bind & report, we should be able to properly align device state with Z2M state, to avoid potential out-of-sync problems (scene on device but not in Z2M or vice versa).

@MfCrizz
Copy link
Author

MfCrizz commented Nov 23, 2025

Makes sense. 🤔 Currently I tested it with one device only in my test network and it was working. Do you know how I can replace this build with the build shipped with the home assistant addon, so I can test it with my other devices too?

I see, would be cool if the scene stuff was improved! I'm sadly not that deep into zigbee and Z2M yet, so not sure if/how I could help you?

@Nerivec
Copy link
Owner

Nerivec commented Nov 23, 2025

If you are using the add-on, it should just be about replacing the content of the nginx dir with the built dist you get with your changes. However, HA does not make it really easy to mount stuff in add-on containers 😅

I already started working on the scene stuff from the lower levels, but next release of Z2M will get quite a few changes, and there are a lot of changes with that one alone, so, don't want to pile up too much, and definitely won't be ready anyway. Will be in a release after new year, if we can get somewhere good with it 😉

@MfCrizz
Copy link
Author

MfCrizz commented Nov 30, 2025

I connected my custom build to my Zigbee2MQTT instance running in Home Assistant and tested the feature with my groups. My largest group has 28 members, mostly Philips Hue devices, but also Osram, Sonoff, MiBoxer, and Tuya. Updating scenes like this worked. :)

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.

2 participants