Skip to content

DDF for Aqara LED Strip T1 (LGYCDD01LM)#8162

Draft
Sumd84 wants to merge 9 commits intodresden-elektronik:masterfrom
Sumd84:master
Draft

DDF for Aqara LED Strip T1 (LGYCDD01LM)#8162
Sumd84 wants to merge 9 commits intodresden-elektronik:masterfrom
Sumd84:master

Conversation

@Sumd84
Copy link
Copy Markdown

@Sumd84 Sumd84 commented Apr 7, 2025

I tried to continue the work of @ebaauw (#7201) on the Aqara LED Strip T1 with the implementation of :

  • Control of music sync effect and sensitivity
  • Control of preset effect and preset speed

I also propose to change the gradient/pixel_count to gradient/segments to not confuse with pixel_count of the Hue product.

Sumd84 and others added 5 commits March 27, 2025 11:54
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 ebaauw self-requested a review April 7, 2025 20:48
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2025

Hey @Sumd84, thanks for your pull request!

Tip

Modified bundles can be downloaded here.
Relative expire date

DDB changes

Modified

  • xiaomi/lumi_light_acn132.json : LED strip T1 (LGYCDD01LM) ✔️

Validation

Tip

Everything is fine !

🕠 Updated for commit d5fa3d5

Copy link
Copy Markdown
Collaborator

@ebaauw ebaauw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",
Copy link
Copy Markdown
Collaborator

@ebaauw ebaauw Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please re-use state/effect and cap/color/effects. Also, "preset" sounds like a config item, not a state item.

Comment thread rest_lights.cpp

if (hasMusicSyncEffect)
{
change.addTargetValue(RStateMusicSyncEffect, targetMusicSyncEffect);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread rest_lights.cpp

if (hasMusicSyncSensitivity)
{
change.addTargetValue(RStateMusicSyncSensitivity, targetMusicSyncSensitivity);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark

Comment thread rest_lights.cpp

if (hasPresetEffect)
{
change.addTargetValue(RStatePresetEffect, targetPresetEffect);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark.

Comment thread rest_lights.cpp

if (hasPresetSpeed)
{
change.addTargetValue(RStatePresetSpeed, targetPresetSpeed);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark.

Comment thread rest_lights.cpp
if (ok)
{
valueOk = true;
change.addTargetValue(RConfigColorGradientSegments, segments);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark.

@Sumd84 Sumd84 marked this pull request as draft June 25, 2025 08:23
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