DDF for Aqara LED Strip T1 (LGYCDD01LM)#8162
DDF for Aqara LED Strip T1 (LGYCDD01LM)#8162Sumd84 wants to merge 9 commits intodresden-elektronik:masterfrom
Conversation
Credit to Zigbee2MQTT project (https://github.com/Koenkk/zigbee-herdsman-converters), on which I gathered the new attributes for preset effects control. Add control of preset effect. Add full control of music sync by adding effect and sensitivity. Slight refactor of the length configuration by using Segments in place of PixelCount. * Update general.xml The Aqara LED Strip T1 provides 7 preset effects available via lumi.specific cluster: - Attribut 0x051F: Selection of one of the 7 preset effects - Attribut 0x0520: Set the speed of the selected preset effect * Update resource.cpp/.h Add new attributes for Aqara LED Strip T1 music sync and preset effect control: - RStateMusicSyncEffect = "state/music_sync_effect" - RStateMusicSyncSensitivity = "state/music_sync_sensitivity" - RStatePresetEffect = "state/preset_effect" - RStatePresetSpeed = "state/preset_speed" - RConfigColorGradientSegments = "config/color/gradient/segments" * Update lumi_light_acn132.json Add attributes for music sync and preset effects control: - "state/music_sync_effect" - "state/music_sync_sensitivity" - "state/preset_effect" - "state/preset_speed" Rename "config/color/gradient/pixel_count" into "config/color/gradient/segments" * Create state_music_sync_effect_item.json * Create state_music_sync_sensitivity_item.json * Create state_preset_effect_item.json * Create state_preset_speed_item.json * Create config_color_gradient_segments_item.json
Add control of preset effect.
Add full control of music sync by adding effect and sensitivity.
Slight refactor of the length configuration by using Segments in place of PixelCount.
* Update rest_lights.cpp
Add handling of the following attributs:
- RStateMusicSyncEffect ("state/music_sync_effect")
- RStateMusicSyncSensitivity "state/music_sync_sensitivity")
- RStatePresetEffect "state/preset_effect")
- RStatePresetSpeed ("state/preset_speed")
- RConfigColorGradientSegments ("config/color/gradient/segments")
ebaauw
left a comment
There was a problem hiding this comment.
Please re-use existing items rather than inventing new ones.
Please don't use C++ code for features that can be handled by DDFs.
| @@ -0,0 +1,8 @@ | |||
| { | |||
| "schema": "resourceitem1.schema.json", | |||
| "id": "config/color/gradient/segments", | |||
There was a problem hiding this comment.
Hue have cap/color/gradient/pixel_count as a hardware capability. It reports the number of individually addressable "hardware areas" (as indicated by the cut markers), taking into account any LED strip extensions or cut-offs. The length of each "hardware area" is reported through pixel_length.
Aqara cannot detect extensions nor cut offs, so the number of "hardware areas" needs to be set, hence config/color/gradient/pixel_count (instead of cap/...). It has exactly the same meaning as for Hue: the number of individually addressable "hardware areas".
Hue doesn't support setting each "hardware area" independently over Zigbee. Instead, you set "software areas" or "segments" through the state. The maximum number of "software areas" that can be defined is reported under cap/color/gradient/max_segments. Typically this number is half the number of "hardware areas" or "pixels". When setting N different software areas, the LED strip firmware splits the total length up in N+1 areas, where the odd areas are set over ZIgbee, and the even areas set by the LED strip firmware, by extrapolating the adjacent colours for a smooth transition.
As I understand it, Aqara does allow to set each hardware area individually, so max_segments equals pixel_count. I'm happy for both to be exposed, but please call it max_segments. The actually number of segments areas with the same colour is set through the state.
There was a problem hiding this comment.
I will switch back to your previous implementation of config/color/gradient/pixel_count to maintain compatibility.
| "datatype": "UInt8", | ||
| "access": "RW", | ||
| "public": true, | ||
| "description": "Number of 20cm segments on Aqara LED Strip T1." |
There was a problem hiding this comment.
The 20cm is reported through cap/color/gradient/pixel_length and shouldn't be part of the description. Also, this would lead to a new item for each new device.
| @@ -0,0 +1,8 @@ | |||
| { | |||
| "schema": "resourceitem1.schema.json", | |||
| "id": "state/music_sync_effect", | |||
There was a problem hiding this comment.
I would prefer to group the state/music_sync attributes, so this would be renamed to state/music_sync/effect. We would also need to change state/music_sync to state/music_sync/on.
I think the values should be reported as strings in the API, and we need a cap item to report the possible values.
| @@ -0,0 +1,8 @@ | |||
| { | |||
| "schema": "resourceitem1.schema.json", | |||
| "id": "state/music_sync_sensitivity", | |||
There was a problem hiding this comment.
Same remarks: state/music_sync/sensitivity, report the values as string, and provide a cap item with the possible values.
| @@ -0,0 +1,8 @@ | |||
| { | |||
| "schema": "resourceitem1.schema.json", | |||
| "id": "state/preset_effect", | |||
There was a problem hiding this comment.
Please re-use state/effect and cap/color/effects. Also, "preset" sounds like a config item, not a state item.
|
|
||
| if (hasMusicSyncEffect) | ||
| { | ||
| change.addTargetValue(RStateMusicSyncEffect, targetMusicSyncEffect); |
There was a problem hiding this comment.
Why is this implemented in C++? DDFs are perfectly capable of writing an attribute or sending a command based on a single item. C++ code would be needed only when multiple items need to be combined into a single attribute or command (like setting xy).
There was a problem hiding this comment.
I thought that both DDFs and C++ need to be modified to open new attributes on the rest API. If DDF alone is sufficient, I'll revert the C++ modification.
There was a problem hiding this comment.
I believe I may have missed something in the DDF, but it’s clear that without modifying the C++ code, I cannot expose or call the new attributes.
With my compiled plugin version, I can now access /state/preset_effect through the API.
If there is a way to access these attributes via the API without modifying the C++ code, I would appreciate a clear explanation.
|
|
||
| if (hasMusicSyncSensitivity) | ||
| { | ||
| change.addTargetValue(RStateMusicSyncSensitivity, targetMusicSyncSensitivity); |
|
|
||
| if (hasPresetEffect) | ||
| { | ||
| change.addTargetValue(RStatePresetEffect, targetPresetEffect); |
|
|
||
| if (hasPresetSpeed) | ||
| { | ||
| change.addTargetValue(RStatePresetSpeed, targetPresetSpeed); |
| if (ok) | ||
| { | ||
| valueOk = true; | ||
| change.addTargetValue(RConfigColorGradientSegments, segments); |
I tried to continue the work of @ebaauw (#7201) on the Aqara LED Strip T1 with the implementation of :
I also propose to change the gradient/pixel_count to gradient/segments to not confuse with pixel_count of the Hue product.