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

[fronius] Support setting backup reserved battery capacity #18080

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

florian-h05
Copy link
Contributor

Description

This PR adds support to the Fronius Symo inverter Thing actions to set the reserved battery capacity for backup power supply.

Testing

Tested with my Fronius Symo inverter.

@florian-h05 florian-h05 requested a review from trokohl as a code owner January 10, 2025 09:46
@florian-h05 florian-h05 changed the title [fronius] Add support for setting backup reserved battery capacity [fronius] Support setting backup reserved battery capacity Jan 10, 2025
@florian-h05 florian-h05 added the enhancement An enhancement or new feature for an existing add-on label Jan 10, 2025
@florian-h05 florian-h05 requested a review from jlaur January 10, 2025 10:06
@florian-h05
Copy link
Contributor Author

@jlaur Can I add myself to the CODEOWNERS of the Fronius binding?

@jlaur
Copy link
Contributor

jlaur commented Jan 10, 2025

Can I add myself to the CODEOWNERS of the Fronius binding?

It would be nice if @trokohl could confirm/approve this.

@trokohl, I can see you are still active on GitHub, but haven't created PR's in this repository since openHAB 2.4 and last reviewed a PR in 2021 for openHAB 3.2.

Is it okay with you if @florian-h05 is added as maintainer for this binding? Do you want to stay as a maintainer also in this case?

@florian-h05
Copy link
Contributor Author

It would be nice if @trokohl could confirm/approve this.

Sure 👍
I would suggest to do the CODEOWNERS change in a separate PR if it is approved,
and keep this PR here as is so it can be reviewed soon.

@jlaur
Copy link
Contributor

jlaur commented Jan 10, 2025

I would suggest to do the CODEOWNERS change in a separate PR if it is approved

Yes, I also think that would be better.

@florian-h05
Copy link
Contributor Author

@jlaur Could you please do me a favour and review this soon? Can't wait to use it to optimise my solar production self-consumption ...

@jlaur
Copy link
Contributor

jlaur commented Jan 16, 2025

Could you please do me a favour and review this soon?

I'm not sure why you requested a review from me specifically, since I don't remember looking into this binding previously. But I can still try to have a look, sure. 🙂 From a brief look, my first question before going deeper is: Why provide this as a thing action rather than a channel?

Can't wait to use it to optimise my solar production self-consumption

I think you can already by installing the JAR? 😉

@florian-h05
Copy link
Contributor Author

Sorry, I thought you reviewed my last large Fronius PR, but it was @lsiepel.

Why provide this as a thing action rather than a channel?

I have actually thought about this myself, but came to the conclusion that it is better provided as a thing action as I don‘t get state for this from the inverter (technically this should be possible, but I don‘t think we should spam the config endpoints that are not intended for API consumption with regularly update requests).

I think you can already by installing the JAR? 😉

Yeah, but it‘s always better to have everything in the distro …

@jlaur
Copy link
Contributor

jlaur commented Jan 16, 2025

Why provide this as a thing action rather than a channel?

I have actually thought about this myself, but came to the conclusion that it is better provided as a thing action as I don‘t get state for this from the inverter (technically this should be possible, but I don‘t think we should spam the config endpoints that are not intended for API consumption with regularly update requests).

It's perfectly possible to have a write-only channel, although not very common. If you don't want it to have a state at all, even when receiving a command, it could use the veto auto-update policy.

Perhaps a write-only channel could be first step, it should be at least as easy to use as a thing action? That would make it possible to set it from various standard UI's, from the console, etc. And of course still from rules. Looking from the other side, what is the advantage of a thing action compared to a write-only channel?

As said, I don't know the binding well, but looked it up now, and can see it's an inverter with a local API. Do you really think it would be an issue to fetch the initial value when the handler is initialized, and the perhaps poll it with as low frequency as it makes sense? How often would it normally change? Is the channel could (at some point) be made readable as well, I think having it as a channel would be far more convenient than as an action.

Just consider it. I think it's better to have this discussion now than later (and now you probably regret having requested my review by mistake 😄).

@florian-h05
Copy link
Contributor Author

It's perfectly possible to have a write-only channel, although not very common. If you don't want it to have a state at all, even when receiving a command, it could use the veto auto-update policy.

Feels kind of awkward to be honest.

Looking from the other side, what is the advantage of a thing action compared to a write-only channel?

Having this as a Thing action would be consistent and inline with the other battery control capabilities.

As already said, it is technically possible to read the value, but this value is nothing to be changed by a user on the fly, it’s rather something to be controlled by rules based on solar production forecast. Normally, you set this setting once during installation of the inverter and never touch it again — the reason I want to programmatically modify it from rules!, is that during winter I want to optimise self-consumption by having a lower emergency reserve capacity, but if the forecast is bad, have more backup capacity available. This is nothing that a user would do manually, and as a thing action it is then easier to use from rules than having to link an item to a write only channel.

@florian-h05 florian-h05 marked this pull request as draft January 19, 2025 17:58
@florian-h05 florian-h05 marked this pull request as ready for review January 20, 2025 09:15
@lsiepel
Copy link
Contributor

lsiepel commented Jan 20, 2025

Will review this PR, but:

I think it's better to have this discussion now than later (and now you probably regret having requested my review by mistake 😄).

haha, and as you stareted this discussion, i won't take over, so you might regret bringing this up ;-)

Anyway, ping me when all is set to proceed.

@jlaur
Copy link
Contributor

jlaur commented Jan 20, 2025

Having this as a Thing action would be consistent and inline with the other battery control capabilities.

As already said, it is technically possible to read the value, but this value is nothing to be changed by a user on the fly, it’s rather something to be controlled by rules based on solar production forecast. Normally, you set this setting once during installation of the inverter and never touch it again — the reason I want to programmatically modify it from rules!, is that during winter I want to optimise self-consumption by having a lower emergency reserve capacity, but if the forecast is bad, have more backup capacity available. This is nothing that a user would do manually, and as a thing action it is then easier to use from rules than having to link an item to a write only channel.

OK, let's keep this as a Thing action then. @lsiepel - ready to proceed. 😉

Signed-off-by: Florian Hotze <[email protected]>
@florian-h05 florian-h05 requested a review from jlaur January 22, 2025 11:14
@florian-h05
Copy link
Contributor Author

@jlaur I addressed your review, please have another look.
I think this weird PercentType construction and intValue() order came because I started with one and added the other one later without rechecking if it makes sense that way.

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, LGTM!

@jlaur jlaur merged commit 76e4db2 into openhab:main Jan 22, 2025
2 checks passed
@jlaur jlaur added this to the 5.0 milestone Jan 22, 2025
@florian-h05 florian-h05 deleted the fronius branch January 22, 2025 15:10
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