dresden-elektronik / deconz-rest-plugin

deCONZ REST-API plugin to control ZigBee devices
BSD 3-Clause "New" or "Revised" License
1.9k stars 503 forks source link

API sends wrong _Enhanced Add Scene_ payload #4271

Open ebaauw opened 3 years ago

ebaauw commented 3 years ago

Describe the bug

When doing a PUT request to add or modify a scene state, deCONZ sends the Enhanced Add Scene command, providing an extension field set for all clusters the light supports, instead of only for the clusters corresponding to attributes specified in the request body.

Steps to reproduce the behavior

$ ph put /groups/220/scenes/1/lights/221/state '{"on": true, "bri": 254}'
{
  "id": "1"
}

Results in:

IEEE 802.15.4 Data, Dst: 0x37b2, Src: 0x0000
ZigBee Network Layer Data, Dst: 0x37b2, Src: 0x0000
ZigBee Application Support Layer Data, Dst Endpt: 11, Src Endpt: 1
ZigBee Cluster Library Frame
    Frame Control Field: Cluster-specific (0x11)
    Sequence Number: 138
    Command: Enhanced Add Scene (0x40)
    Payload, String: 
        Group ID: 0x00dc
        Scene ID: 0x01
        Transition Time: 0.4 seconds
        Length: 0
        String: 
        Extension field set 1
            Cluster: On/Off (0x0006)
            On/Off: 1
        Extension field set 2
            Cluster: Level Control (0x0008)
            Level: 254
        Extension field set 3
            Cluster: Color Control (0x0300)
            Color X: 0.4592
            Color Y: 0.4107
            Enhanced Hue: 0
            Saturation: 0
            Color Loop Active: False
            Color Loop Direction: Hue is Decrementing (0)
            Color Loop Time: 0 seconds

Expected behavior

Only include extension field sets for On/Off and Level Control, as the Hue bridge does:

$ ph post /scenes '{"name": "test", "lights": ["25"], "lightstates": {"25": {"on": true, "bri": 254}}, "recycle": false}'
"ZcOydYdPWUtX89m"

Results in:

IEEE 802.15.4 Data, Dst: 0x0002, Src: 0x0001
ZigBee Network Layer Data, Dst: 0x0002, Src: 0x0001
ZigBee Application Support Layer Data, Dst Endpt: 11, Src Endpt: 64
ZigBee Cluster Library Frame
    Frame Control Field: Cluster-specific (0x01)
    Sequence Number: 55
    Command: Enhanced Add Scene (0x40)
    Payload, String: 
        Group ID: 0x778f
        Scene ID: 0x0c
        Transition Time: 0.4 seconds
        Length: 0
        String: 
        Extension field set 1
            Cluster: On/Off (0x0006)
            On/Off: 1
        Extension field set 2
            Cluster: Level Control (0x0008)
            Level: 254

Note that the Hue bridge also correctly reports the scene with only on and bri. Double-checked that recalling the scene only changes On/Off and Current Level, leaving colour or colour temperature intact.

$ ph get /scenes/ZcOydYdPWUtX89m
{
  "name": "test",
  "type": "LightScene",
  "lights": [
    "25"
  ],
  "owner": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "recycle": false,
  "locked": false,
  "appdata": {},
  "picture": "",
  "lastupdated": "2021-01-24T14:17:26",
  "version": 2,
  "lightstates": {
    "25": {
      "on": true,
      "bri": 254
    }
  }
}

Screenshots

N/a

Environment

deCONZ Logs

N/a

Additional context

N/a

github-actions[bot] commented 3 years ago

As there has not been any response in 21 days, this issue has been automatically marked as stale. At OP: Please either close this issue or keep it active It will be closed in 7 days if no further activity occurs.