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

[solarforecast] Initial contribution #13308

Merged
merged 111 commits into from
May 2, 2024
Merged

Conversation

weymann
Copy link
Contributor

@weymann weymann commented Aug 23, 2022

Solar Forecast binding for two diferent free photovoltaic forecast services

Binding is provided on Marketplace.

The binding is running pretty stable on my side but I need your opinion regarding the Actions interface
Is LocalDateTime'sufficient or is ZonedDateTime the way to go?

@weymann weymann requested a review from a team as a code owner August 23, 2022 22:30
@wborn wborn added the new binding If someone has started to work on a binding. For a new binding PR. label Aug 26, 2022
@jlaur jlaur changed the title [solarforecast] initial contribution [solarforecast] Initial contribution Aug 29, 2022
@jlaur
Copy link
Contributor

jlaur commented Aug 30, 2022

@weymann - thanks for this contribution! I have now slightly started a review. Would it be possible for you to do one self-review iteration with #13044 in mind to avoid some redundancy? For example i18n for updateStatus(), usage of Instant over LocalDateTime to avoid clock issues, etc.

@weymann
Copy link
Contributor Author

weymann commented Sep 4, 2022

I'll do as you suggested. Was developed in parallel to Mercedes binding so I can imagine some similar findings.
Put "WIP" in headline and I'll remove it as soon as I'm done.

@weymann weymann changed the title [solarforecast] Initial contribution [WIP] [solarforecast] Initial contribution Sep 4, 2022
@wborn wborn added the work in progress A PR that is not yet ready to be merged label Nov 6, 2022
@weymann weymann changed the title [WIP] [solarforecast] Initial contribution [solarforecast] Initial contribution Jun 8, 2023
@weymann
Copy link
Contributor Author

weymann commented Jun 8, 2023

WIP removed

  • Logging adapted
  • i18n for status upates and rule actions updated
  • usage of Instant for internal measurements
  • package rework

@weymann weymann requested review from wborn and lsiepel June 8, 2023 20:30
@lsiepel lsiepel removed awaiting feedback work in progress A PR that is not yet ready to be merged labels Jun 9, 2023
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.

Thank you for your contribution, and sorry for the long delay! I almost made it for the one year anniversary. I have provided my feedback for my first iteration review.

The binding is running pretty stable on my side but I need your opinion regarding the Actions interface
Is LocalDateTime'sufficient or is ZonedDateTime the way to go?

I would actually suggest Instant, but I might be alone with this opinion. LocalDateTime seems not ideal since there can be ambiguity, for example during DST. It can suddenly change when time-zone settings are changed. Therefore ZonedDateTime would be better. The reason I'm proposing Instant is because you actually don't need the time-zone to be provided, only the exact moment in time. You can always get the current time-zone through TimeZoneProvider.

Historically ZonedDateTime is better supported, for example it's currently the native type for DateTimeType. However, Instant has also recently gotten some attention in openhab-js. See also openhab/openhab-core#2898

bundles/org.openhab.binding.solarforecast/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.solarforecast/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.solarforecast/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.solarforecast/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.solarforecast/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.solarforecast/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.solarforecast/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.solarforecast/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.solarforecast/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.solarforecast/README.md Outdated Show resolved Hide resolved
@weymann
Copy link
Contributor Author

weymann commented Sep 19, 2023

@jlaur
I looked into the discussion regarding Instant or ZonedDateTime as base for DateTimeType. Deep discussion regarding compatibility and so on.

Switch now perspective to an openHAB user with no deep technical background. And we want to attract new users, right?
The user wants to know some "simple" values

  • energy production of tomorrow: LocalDate.now.plusDays(1)
  • power prediction one hour ahead: LocalDateTime.now.plusHours(1)
  • power prediction at 16:13: LocalDateTime:now.withHour(16).withMinute(13)

In my opinion I can very easily explain the Interface with plusX, withX, minusX functions on LocalDateTime.
With Instant it would look very different.

@jlaur
Copy link
Contributor

jlaur commented Sep 30, 2023

I looked into the discussion regarding Instant or ZonedDateTime as base for DateTimeType. Deep discussion regarding compatibility and so on.

Switch now perspective to an openHAB user with no deep technical background. And we want to attract new users, right? The user wants to know some "simple" values

  • energy production of tomorrow: LocalDate.now.plusDays(1)
  • power prediction one hour ahead: LocalDateTime.now.plusHours(1)
  • power prediction at 16:13: LocalDateTime:now.withHour(16).withMinute(13)

All of those classes have their reasons to exist, we just need to use the right classes for the right purposes. First, let's not mix dates and datetimes.

I'm not sure exactly what you want to discuss here, since there are many subtopics. But if we focus on what I assume is thing action examples/rule code: What exactly do you expect from LocalDateTime.now.plusHours(1)? This will use the system default time-zone, not the time-zone configured in openHAB. See public static LocalDateTime now(). So when using an openHAB system in another time-zone, this will simply not work, since TimeZoneProvider is not considered.

How will you, using LocalDateTime, manage ambiguous moments in time when switching from DST to non-DST, i.e. when offsets change in a backward direction?

In my opinion I can very easily explain the Interface with plusX, withX, minusX functions on LocalDateTime. With Instant it would look very different.

Instant also have public Instant plus(long amountToAdd, TemporalUnit unit)

@weymann
Copy link
Contributor Author

weymann commented Nov 19, 2023

After investigating Energi Data Service binding usage of Instant is clear for me now.

  • actions interface changed also to Instant usage
  • first internal tests running fine
  • release candidate updated in community / marketplace page

@weymann weymann requested a review from jlaur November 19, 2023 22:08
@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/solar-forecast-pv/137681/123

@mstormi
Copy link
Contributor

mstormi commented Dec 7, 2023

@jlaur Jacob do you mind finishing this review so we could still get this into 4.1? Thanks.

Signed-off-by: Bernd Weymann <[email protected]>
@jlaur
Copy link
Contributor

jlaur commented Apr 27, 2024

@weymann - I checked for open comments the other day and found one that I had missed previously. Can you recheck this? #13308 (comment)

Signed-off-by: Bernd Weymann <[email protected]>
Signed-off-by: Bernd Weymann <[email protected]>
@soenkekueper
Copy link
Contributor

Now my bridge goes online, but my two planes stay offline with COMMUNICATION_ERROR and HTTP Status Code 401.

Yes, known issue. Last 2 commits contains fixes after testing the version on my side. Bote services are up and running now.

Hey,

thanks for the fast fixing.
I've just installed the latest version
336 │ Active │ 80 │ 4.2.0.202404281527 │ openHAB Add-ons :: Bundles :: SolarForecast Binding

Doesn't work yet :/
The Bridge goes offline and states:
Exception during update: solarforecast:sc-plane:1412a57284:a7bb1eafb0 # Forecast invalid time range
so the two defined planes stay offline:bridge.

The log states:

2024-04-28 19:36:53.048 [TRACE] [.solcast.handler.SolcastPlaneHandler] - Get new forecast Expiration: 2024-04-28T17:36:23.504336188Z, Data: {}
2024-04-28 19:36:55.343 [DEBUG] [.solcast.handler.SolcastPlaneHandler] - Solcast Hauptdach Call https://api.solcast.com.au/rooftop_sites/d4dc-xxxx-yyyy-e4fa/estimated_actuals?format=json failed 403
2024-04-28 19:36:55.366 [TRACE] [.solcast.handler.SolcastPlaneHandler] - Get new forecast Expiration: 2024-04-28T17:36:44.903449277Z, Data: {}
2024-04-28 19:36:57.252 [DEBUG] [.solcast.handler.SolcastPlaneHandler] - Solcast Anbau Call https://api.solcast.com.au/rooftop_sites/b243-xxxx-yyyy-09bf/estimated_actuals?format=json failed 403

Is it right, that the expiration time is 30 seconds past the current time? Which timestamp is ment here?

So should i continue testing at the moment or do you have some further known issues, you're working on?

BR Sönke

@jlaur
Copy link
Contributor

jlaur commented Apr 28, 2024

@weymann - we are getting close. Two comments still open from this: #13308 (review). There are also some compiler warnings to address. And I'm wondering if this needs to be investigated/resolved before merging: #13308 (comment)?

@weymann
Copy link
Contributor Author

weymann commented Apr 28, 2024

Solcast Hauptdach Call https://api.solcast.com.au/rooftop_sites/d4dc-xxxx-yyyy-e4fa/estimated_actuals?format=json failed 403

Did you register for Hobbyist Plan and is it verified by Solcast ?
As you can see in the response table return code 403 says that you're not allowed to access this API.
image

Signed-off-by: Bernd Weymann <[email protected]>
@soenkekueper
Copy link
Contributor

Yes i've a valid registration and the plugin was running some time ago and i did not change the configuration.

So to be sure, i've just generated a new api-key, now its running fine.

Thanks for your work!

@weymann
Copy link
Contributor Author

weymann commented Apr 30, 2024

to address. And I'm wondering if this needs to be investigated/resolved before merging: #13308 (comment)?

This was config issue, not code. Reported as fixed in latest comment.

Issue weymann/OH3-SolarForecast-Drops#5 (comment) was reported in my drop repository which needs to be fixed

Signed-off-by: Bernd Weymann <[email protected]>
Signed-off-by: Bernd Weymann <[email protected]>
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.

Some minor nitpicking. Let me know when weymann/OH3-SolarForecast-Drops#5 is fixed and you are ready for merging the PR.

Signed-off-by: Bernd Weymann <[email protected]>
@weymann
Copy link
Contributor Author

weymann commented May 2, 2024

Some minor nitpicking. Let me know when weymann/OH3-SolarForecast-Drops#5 is fixed and you are ready for merging the PR.

Tested commit on my site 3 days with result ok
Reporter of this issue tested also the change with result ok and closed the issue as solved

Ready to merge!

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 again for the contribution! LGTM.

You can now add your binding's logo to the openHAB website and the UI. See https://next.openhab.org/docs/developer/addons/#add-your-add-on-s-logo-to-the-openhab-website-and-the-ui

@jlaur jlaur merged commit 71d335d into openhab:main May 2, 2024
5 checks passed
@jlaur jlaur added this to the 4.2 milestone May 2, 2024
psmedley pushed a commit to psmedley/openhab-addons that referenced this pull request Jun 15, 2024
Signed-off-by: Bernd Weymann <[email protected]>
Signed-off-by: Paul Smedley <[email protected]>
@weymann weymann deleted the solar-forecast branch September 8, 2024 15:23
pgfeller pushed a commit to pgfeller/openhab-addons that referenced this pull request Sep 29, 2024
Signed-off-by: Bernd Weymann <[email protected]>
Signed-off-by: Patrik Gfeller <[email protected]>
joni1993 pushed a commit to joni1993/openhab-addons that referenced this pull request Oct 15, 2024
matchews pushed a commit to matchews/openhab-addons that referenced this pull request Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new binding If someone has started to work on a binding. For a new binding PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants