Skip to content

Supply allowed string values of @AttributeDefinition channels - #3020

Open
Lamarqe wants to merge 1 commit into
OpenEMS:developfrom
Lamarqe:attribute_options
Open

Supply allowed string values of @AttributeDefinition channels#3020
Lamarqe wants to merge 1 commit into
OpenEMS:developfrom
Lamarqe:attribute_options

Conversation

@Lamarqe

@Lamarqe Lamarqe commented Feb 20, 2025

Copy link
Copy Markdown
Contributor

Until now, AttributeDefinition channels (channels, whose names start with _Property) which are based on Enums do not provide the allowed values in their type defintions retrieved via edge call getChannelsOfComponent().

For example the channel ctrlEvcs0/_PropertyChargeMode provides:

    {
        "id": "_PropertyChargeMode",
        "accessMode": "RO",
        "persistencePriority": "HIGH",
        "text": "",
        "type": "STRING",
        "unit": "",
        "category": "OPENEMS_TYPE"
    },

With this pull request, the allowed enum values (which were stored internally already previously) are published correctly:

    {
        "id": "_PropertyChargeMode",
        "accessMode": "RO",
        "persistencePriority": "HIGH",
        "text": "",
        "type": "STRING",
        "unit": "",
        "category": "OPENEMS_TYPE",
        "options": [
            "FORCE_CHARGE",
            "EXCESS_POWER"
        ]
    },

@Sn0w3y

Sn0w3y commented Feb 20, 2025

Copy link
Copy Markdown
Collaborator

Does this solve the Issue

Feb 20 21:56:23 server.io java[1239557]: 2025-02-20T21:56:23,788 [socket-1] WARN [nflux.FieldTypeConflictHandler] [Timedata.InfluxDB] Unable to convert field [_appManager/_PropertyApps] value ["[\n {\n \"appId\": \"App.Api.ModbusTcp.ReadOnly\",\n \"alias\": \"\",\n \"instanceId\": \"876b92bf-0fa4-4dc6-8cfc-cb0d49d3db70\",\n \"properties\": {\n \"CONTROLLER_ID\": \"ctrlApiModbusTcp0\"\n }\n },\n {\n \"appId\": \"App.Api.RestJson.ReadOnly\",\n \"alias\": \"\",\n \"instanceId\": \"5c989095-7496-4ec4-b142-7aafbf03b37c\",\n \"properties\": {\n \"CONTROLLER_ID\": \"ctrlApiRest0\"\n }\n }\n]"] to integer Feb 20 21:56:23 server.io java[1239557]: 2025-02-20T21:56:23,788 [socket-1] WARN [nflux.FieldTypeConflictHandler] [Timedata.InfluxDB] Unable to convert field [_appManager/_PropertyCurrency] value ["EUR"] to integer Feb 20 21:56:23 server.io java[1239557]: 2025-02-20T21:56:23,788 [socket-1] WARN [nflux.FieldTypeConflictHandler] [Timedata.InfluxDB] Unable to convert field [_appManager/_PropertyIgnoreStateComponents] value ["[\"\"]"] to integer Feb 20 21:56:23 server.io java[1239557]: 2025-02-20T21:56:23,788 [socket-1] WARN [nflux.FieldTypeConflictHandler] [Timedata.InfluxDB] Unable to convert field [_appManager/_PropertyKeyForFreeApps] value ["0000-0000-0000-0000"] to integer

?

@Lamarqe

Lamarqe commented Feb 20, 2025

Copy link
Copy Markdown
Contributor Author

No idea.
I don't see any connection to this pull request.

@Lamarqe

Lamarqe commented Feb 26, 2025

Copy link
Copy Markdown
Contributor Author

Is there anything which I need to do in order to receive a review or other feedback about how to proceed?

@codecov

codecov Bot commented Feb 28, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.84211% with 5 lines in your changes missing coverage. Please review.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #3020      +/-   ##
=============================================
+ Coverage      55.64%   55.68%   +0.05%     
- Complexity     19016    19025       +9     
=============================================
  Files           3670     3670              
  Lines         171447   171480      +33     
  Branches       14113    14119       +6     
=============================================
+ Hits           95377    95475      +98     
+ Misses         72302    72232      -70     
- Partials        3768     3773       +5     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sfeilmeier

Copy link
Copy Markdown
Contributor

Thank you for the contribution. I'll need some time to review it in detail. Ideally I would like to not add it to the parent Doc directly as it relates only to Enums. Also the code does not fully align with our coding guidlines (https://openems.github.io/openems.io/openems/latest/contribute/coding-guidelines.html)

@Lamarqe
Lamarqe force-pushed the attribute_options branch 2 times, most recently from a134b79 to 3e24c5c Compare March 9, 2025 21:29
@Lamarqe

Lamarqe commented Mar 9, 2025

Copy link
Copy Markdown
Contributor Author

Thank you for having a first look and taking the time for a full review.
I guess with "parent doc", you refer to Doc.java? I did not find a way to modify only AbstractDoc.java.
Logically, its an enum channel, but technically, it is not. (Its ChannelCategory.OPENEMS_TYPE using OpenemsType.STRING. The only difference is the schema it comes with.)

Regarding the the style warnings: During the last hour, I applied the Eclipse code formatter to all modified files and updated the branch accordingly. PR should be clean now.

@Lamarqe
Lamarqe force-pushed the attribute_options branch 2 times, most recently from a7f7ea9 to 51a27ac Compare March 12, 2025 20:07
@Lamarqe
Lamarqe force-pushed the attribute_options branch from 51a27ac to 7c207a3 Compare March 20, 2025 12:30
@Lamarqe

Lamarqe commented Mar 20, 2025

Copy link
Copy Markdown
Contributor Author

@sfeilmeier : do you think you will find the time to do a full review anytime soon?

@Lamarqe
Lamarqe force-pushed the attribute_options branch 2 times, most recently from 34d5b38 to c0bce96 Compare March 29, 2025 05:48
@Lamarqe
Lamarqe force-pushed the attribute_options branch from c0bce96 to 36e9ed6 Compare April 4, 2025 20:14
@Lamarqe

Lamarqe commented Apr 4, 2025

Copy link
Copy Markdown
Contributor Author

Is there any chance to get this MR merged?
If not, please let me know and share a short explanation

Then I would just close it and stop investing time in doing regularly rebases and retests.

@Sn0w3y

Sn0w3y commented Apr 4, 2025

Copy link
Copy Markdown
Collaborator

Is there any chance to get this MR merged?
If not, please let me know and share a short explanation

Then I would just close it and stop investing time in doing regularly rebases and retests.

If i am honest i do not know the exact Usecase as neither the UI nor any other Component uses them incorrectly - if you would provide a little more Use-Case info it would be good i guess. I am not in the Position to Merge nor to reject - just my Questions! :)

@Lamarqe

Lamarqe commented Apr 5, 2025

Copy link
Copy Markdown
Contributor Author

Yes, valid and good question.

Having this information available in the channel definition will allow for a generic integration into other smart home systems.
Instead of hard-coding behaviors and options, integrations to connected systems can use the information retrieved via the GetChannelsOfComponent reponse to define possible user and system interactions.

One example of such a connected system could be Home Assistant. But this MR is fully independent of the concrete connected system.

@Lamarqe
Lamarqe force-pushed the attribute_options branch from 36e9ed6 to e1a295a Compare April 11, 2025 19:46
@sfeilmeier

Copy link
Copy Markdown
Contributor

Sorry, I hardly find time to work on this feature. The two reasons why I don't immediately accept your current implementation:

@Lamarqe
Lamarqe force-pushed the attribute_options branch from e1a295a to e9abc6d Compare May 1, 2025 17:09
@Lamarqe
Lamarqe force-pushed the attribute_options branch 2 times, most recently from fee0410 to ee8c901 Compare May 26, 2025 20:18
@Lamarqe
Lamarqe force-pushed the attribute_options branch from ee8c901 to d5ac6bb Compare June 2, 2025 21:39
@Lamarqe
Lamarqe force-pushed the attribute_options branch 5 times, most recently from dcd877b to c422d35 Compare August 12, 2025 21:01
@github-actions

github-actions Bot commented Dec 4, 2025

Copy link
Copy Markdown

This PR has been automatically marked as stale due to inactivity

If it is still relevant, please update the PR.
Otherwise, it will be automatically closed in 14 days.

Before updating, please review our Contribution Guidelines to ensure all required information is provided.

@github-actions github-actions Bot added the Stale label Dec 4, 2025
@Lamarqe
Lamarqe marked this pull request as draft December 8, 2025 21:51
@github-actions github-actions Bot removed the Stale label Dec 9, 2025
@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown

This PR has been automatically marked as stale due to inactivity

If it is still relevant, please update the PR.
Otherwise, it will be automatically closed in 14 days.

Before updating, please review our Contribution Guidelines to ensure all required information is provided.

@github-actions github-actions Bot added the Stale label Mar 9, 2026
@Lamarqe
Lamarqe force-pushed the attribute_options branch from 2174ff2 to 68fb9ca Compare March 9, 2026 06:40
@Lamarqe
Lamarqe marked this pull request as ready for review March 9, 2026 07:05
@Lamarqe
Lamarqe marked this pull request as draft March 9, 2026 07:05
@github-actions github-actions Bot removed the Stale label Mar 10, 2026
@Lamarqe
Lamarqe force-pushed the attribute_options branch from 68fb9ca to 8efdd0a Compare April 6, 2026 07:29
@Lamarqe

Lamarqe commented May 10, 2026

Copy link
Copy Markdown
Contributor Author

Hi @sfeilmeier,

As this would be a really valuable addition, I went over it again with the intention to adjust the implementation according to your feedback and create unit test coverage. Regarding your implementation comment:

In EdgeConfig we already parse Enums correctly, when creating the Schema (https://github.com/OpenEMS/openems/blob/develop/io.openems.common/src/io/openems/common/types/EdgeConfig.java#L821). This info would have to be propagated to where the Channel is created (https://github.com/OpenEMS/openems/blob/develop/io.openems.edge.common/src/io/openems/edge/common/component/AbstractOpenemsComponent.java#L306)

This is exactly what my implementation does. The EdgeConfig enum parsing stores the options in the schema field templateOptions->options. My implementation gets this information exactly in the point you recommend ("where the Channel is created") See (https://github.com/Lamarqe/openems/blob/c28f59b9c4c127731a7f05f459cef21a6466a7d9/io.openems.edge.common/src/io/openems/edge/common/component/AbstractOpenemsComponent.java#L359-L364)

If this is not adequate: Could you give a few more details of how you would like to have the implementation changed?

@Lamarqe
Lamarqe force-pushed the attribute_options branch from 8efdd0a to c28f59b Compare May 13, 2026 21:56
@Lamarqe

Lamarqe commented May 14, 2026

Copy link
Copy Markdown
Contributor Author

As part of re-basing, I noticed a recent code change which is similar to the extension made with my PR. This gives me better confidence that my changes are aligned with the existing implementation.

Also, I added today the unit tests requested by Stefan.
With that, I am sending it again for review with the request to merge.

@Lamarqe
Lamarqe marked this pull request as ready for review May 14, 2026 19:22
@Lamarqe
Lamarqe force-pushed the attribute_options branch from 90c7d1e to 4b7688d Compare May 22, 2026 11:39
@Lamarqe

Lamarqe commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@sfeilmeier : Can we please move on with this PR? Earlier review comments have been incorporated / answered.

@da-Kai
da-Kai requested a review from sfeilmeier August 8, 2026 09:37
@Lamarqe
Lamarqe force-pushed the attribute_options branch from 4b7688d to 2babd0e Compare August 21, 2026 21:16
@Lamarqe
Lamarqe force-pushed the attribute_options branch from 2babd0e to 9720e70 Compare August 21, 2026 21:46
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.

3 participants