Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[growatt] Enhance support for SPF inverters #17795

Merged
merged 10 commits into from
Nov 26, 2024

Conversation

andrewfg
Copy link
Contributor

This PR enhances the support for SPF inverters as follows:

  • Adjusts mapping between DTO fields and OH channels to avoid duplicates
  • Adds missing channels for SPF inverters
  • Adds a channel to show the time offset between the inverter clock and the OH system clock

Signed-off-by: AndrewFG software@whitebear.ch

Signed-off-by: AndrewFG <software@whitebear.ch>
Signed-off-by: AndrewFG <software@whitebear.ch>
@andrewfg andrewfg added enhancement An enhancement or new feature for an existing add-on work in progress A PR that is not yet ready to be merged labels Nov 23, 2024
@andrewfg andrewfg self-assigned this Nov 23, 2024
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/growatt-solar-inverter-binding-4-0-0-4-2-0/150600/27

@andrewfg
Copy link
Contributor Author

andrewfg commented Nov 23, 2024

The Jar file for testing is here..

org.openhab.binding.growatt-4.3.0-SNAPSHOT.jar.zip

@andrewfg andrewfg removed the work in progress A PR that is not yet ready to be merged label Nov 24, 2024
@andrewfg andrewfg requested a review from a team November 24, 2024 08:21
Signed-off-by: AndrewFG <software@whitebear.ch>
Signed-off-by: AndrewFG <software@whitebear.ch>
Signed-off-by: AndrewFG <software@whitebear.ch>
@andrewfg andrewfg added work in progress A PR that is not yet ready to be merged and removed work in progress A PR that is not yet ready to be merged labels Nov 24, 2024
Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

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

Thanks! I have added a few comments after a quick read-through.

Signed-off-by: AndrewFG <software@whitebear.ch>
@andrewfg andrewfg added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Nov 24, 2024
@andrewfg andrewfg requested a review from jlaur November 24, 2024 15:15
Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

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

Since new channels were added, update instructions are needed. Otherwise LGTM now.

@andrewfg
Copy link
Contributor Author

Since new channels were added, update instructions are needed.

Hmm. I am not sure if that is necessary -- for the following reasons -- please advise.

  • all new things are created with the full complement of all possible channels; then the unused channels are dynamically removed depending on the Json fields coming from the actual device.
  • the previous set of channels was sufficient for all existing devices, so the added channels do not apply to such things
  • the added channels only apply to the newly reported SPF device

@jlaur
Copy link
Contributor

jlaur commented Nov 24, 2024

  • the added channels only apply to the newly reported SPF device

So it didn't make sense at all to have a Thing for an SPF device before this PR, because it was not supported at all? In that case I agree.

But if you could already create the Thing for such device and use it just without the newly added channels, update instructions are needed, because the user will otherwise have to delete and recreate the Thing in order to have those new channels added.

Signed-off-by: AndrewFG <software@whitebear.ch>
@andrewfg andrewfg requested a review from jlaur November 24, 2024 22:25
@andrewfg
Copy link
Contributor Author

@jlaur I did the update instructions. And as they contain labels and descriptions I also ran mvn i18n:generate-default-translations but was surprised that it did not generate any default texts for those labels and descriptions. So I am wondering if a) there is a bug in OH core, or b) OH core gets the texts from the original thing-type xml; in which case I wonder why it is necessary for the update instructions to have labels and descriptions in them. It is not related directly to this PR but WDYT?

@jlaur
Copy link
Contributor

jlaur commented Nov 25, 2024

I did the update instructions. And as they contain labels and descriptions I also ran mvn i18n:generate-default-translations but was surprised that it did not generate any default texts for those labels and descriptions.

The update instructions don't support I18N directly, so for overridden labels and descriptions on channel level, there are only two possibilities:

  • Include them in update instructions: They will be in English, even if translated.
  • Do not include them in update instructions: Channel type texts will be used (rather than overriden channel texts), but they will be translated.

See openhab/openhab-core#3569 for further details.

@andrewfg
Copy link
Contributor Author

The update instructions don't support I18N

Understood. In this PR I have included the English texts.

(However I am really surprised that nobody is working on a solution for adding i18n to the update instruction semantics in OH core).

@jlaur
Copy link
Contributor

jlaur commented Nov 25, 2024

(However I am really surprised that nobody is working on a solution for adding i18n to the update instruction semantics in OH core).

The right solution is for the update to use the already provided channel labels/descriptions, like it does for channel types, but it seems it's hard to do. There is also openhab/openhab-core#3660 related to this topic.

@andrewfg
Copy link
Contributor Author

The right solution is for the update to use the already provided channel labels/descriptions

Perhaps I am missing something .. but it seems to me that in the doChannel() method (see link below) it should be possible to query the registry and get the channel label and description from the old channel, and (if no 'label' or 'description' is provided in the update instruction) apply those to the new channel. Or ??

https://github.com/openhab/openhab-core/blob/660102e3f93f928473b66f56f2955090dfa3c30e/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/update/UpdateChannelInstructionImpl.java#L106

@jlaur
Copy link
Contributor

jlaur commented Nov 25, 2024

but it seems to me that in the doChannel() method (see link below) it should be possible to query the registry and get the channel label and description from the old channel, and (if no 'label' or 'description' is provided in the update instruction) apply those to the new channel. Or ??

Can you put that comment in the linked issue?

@jlaur jlaur changed the title [growatt] Enhanced support for SPF inverters [growatt] Enhance support for SPF inverters Nov 25, 2024
Signed-off-by: AndrewFG <software@whitebear.ch>
@jlaur
Copy link
Contributor

jlaur commented Nov 25, 2024

Can you put that comment in the linked issue?

I meant to put that comment into openhab/openhab-core#3569, so that the relevant people will see it.

Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

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

LGTM, but commented a few places as you may have misunderstood my last comment? Also looks a bit unusual to document date of changes in the code. But really minor, so just consider, I will merge anyway.

@andrewfg
Copy link
Contributor Author

Can you put that comment in the linked issue?

Done.

@jlaur jlaur merged commit 81e488d into openhab:main Nov 26, 2024
5 checks passed
@jlaur jlaur added this to the 4.3 milestone Nov 26, 2024
@andrewfg andrewfg deleted the growatt-extend-channel branch November 26, 2024 11:57
matchews pushed a commit to matchews/openhab-addons that referenced this pull request Dec 16, 2024
* [growatt] tweak channel aliases; add missing channels

Signed-off-by: AndrewFG <software@whitebear.ch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants