dresden-elektronik / deconz-rest-plugin-v2

deCONZ REST-API version 2 development repository.
BSD 3-Clause "New" or "Revised" License
17 stars 0 forks source link

Scenes #5

Open manup opened 3 years ago

manup commented 3 years ago

The current handling of scenes doesn't work very well for some devices and has some general issues. Here is a first draft how to approach a new scenes implementation. It's not complete but should provides a base for discussion and comments.

Observations

The future implementation as part of the Device state machine needs to be able to do the following tasks. These are described in a coarse state machine.

Device scene specifics

Create a scene

Recall a scene

Verify scene after recall

Remarks: IKEA lights set scene valid attribute to false for On/Off and Brightness commands but not when changing only the color.

Verify scene state

Store scene state

Set scene state

Notes

Related: https://github.com/dresden-elektronik/deconz-rest-plugin/pull/3497

ebaauw commented 3 years ago

I think this will work, but to be honest, it looks a bit over complicated to me.

In addition to Recall Scene, I’d simply send unicast commands to the lights that:

You could loop over all lights sending a unicast Store Scene for confirmation that the (whitelisted) light has actually accepted the scene.

I think it’s more the responsibility of the API client to implement non-Zigbee scenes (and groups).

manup commented 3 years ago

Thanks for the review, I have to admit it has a certain complexity :) but within the state machine it's rather simple to implement with (hopefully) very little maintenance, surprisingly the actual code is relative small for what it can do. I'd really like to aim for a max. robust solution which just works, plus implicit goodies like auto repairing scenes and no scaling issues. Mainly because this can get rid of all issues users are currently facing and to bring related support cases down.

In addition to Recall Scene, I’d simply send unicast commands to the lights that:

  • Aren’t whitelisted to support the Scenes cluster sufficiently;
  • Lights whose Scenes table is full (so part of the “sufficient” support is reporting correctly the available entries).

I agree this should happen right after recalling a scene for such devices. Basically it's a fast forward to the "Set scene state" state.

You could loop over all lights sending a unicast Store Scene for confirmation that the (whitelisted) light has actually accepted the scene.

This is done in the "Store scene state" automatically after a scene state has been set, I think this should do the trick.

I think it’s more the responsibility of the API client to implement non-Zigbee scenes (and groups).

Here the problem is that this would bring the burden to understand and communicate that to the end user. Users usually don't understand nor care about this, they have their lights and want to use scenes. Since the "Set scene state" state is used for both kinds of devices there is little overhead to support devices which don't have Zigbee scenes, we only need move to that state and machine will do its thing. The related REST-API and end user interfaces has one unified solution which is hopefully simple to understand and use.