openems icon indicating copy to clipboard operation
openems copied to clipboard

Include keys in components object in edge config

Open jpdark opened this issue 2 years ago • 6 comments

The id is a property of the model that is represented by each object, so including it in that representation is desirable. Same goes for the channels when included in the components.

This benefits (de)serialization in clients for the edge config api.

jpdark avatar Mar 21 '23 09:03 jpdark

Hi there, the changes look ok to me.

Can you please elaborate a bit why this change is useful? Do you plan any feature that depend on the ids?

Increasing the API surface should be done only after a discussion :)

hydroid7 avatar Mar 22 '23 21:03 hydroid7

Hi there,

Thanks for asking about our use-case and considering this PR.

The more specific and practical reason I'm using Kotlinx serialization library, with polymorphism based on content of the id's that we're using (relying on conventions). This content-based polymorphism works on exactly that: the content of the object, not its key.

A more generic argument In general, I think it is good practice to enclose all information about an entity (including its identity) in the object itself, not in both object + key. Since this is an extension of the API, I feel it should have low impact to existing use.

I decided to make these minor changes to our fork of OpenEMS, rather than work around the limitation.

Keen to hear your view on this.

jpdark avatar Mar 28 '23 14:03 jpdark

@hydroid7 Would love to hear what you think. Keen to merge (or close) this PR.

jpdark avatar May 01 '23 13:05 jpdark

Thanks @hydroid7. I'm not 100% sure what you are requesting. My understanding is that you would like:

  • a larger PR (🤔 ?)
  • additional documentation for getEdgeConfig rpc

I hope to address both with 2 additional commits. Thanks.

jpdark avatar May 02 '23 09:05 jpdark

Thank you for the docs, it looks good.

hydroid7 avatar May 02 '23 19:05 hydroid7

Hi @sfeilmeier I would like to finish this minor addition to the OpenEMS codebase. Hopefully you can give it the green light soon, expecially given it's a small change with low impact. Thanks for considering

uneti-jaap avatar May 25 '23 10:05 uneti-jaap