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

[weatherunderground] Consider TimeZoneProvider to get the timezone #7878

Merged
merged 2 commits into from
Jun 9, 2020

Conversation

lolodomo
Copy link
Contributor

@lolodomo lolodomo commented Jun 8, 2020

Also fix few warnings about null check

Signed-off-by: Laurent Garnier [email protected]

Also fix few warnings about null check

Signed-off-by: Laurent Garnier <[email protected]>
@TravisBuddy
Copy link

Travis tests were successful

Hey @lolodomo,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@@ -82,7 +86,7 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();

if (thingTypeUID.equals(THING_TYPE_WEATHER)) {
return new WeatherUndergroundHandler(thing, localeProvider, unitProvider);
return new WeatherUndergroundHandler(thing, localeProvider, unitProvider, timeZoneProvider.getTimeZone());
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the timeZoneProvider be passed in its entirety to allow users to change the timezone without having to recreate the handler?

Copy link
Contributor Author

@lolodomo lolodomo Jun 8, 2020

Choose a reason for hiding this comment

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

At the first reading, I did not understand your point. But now I realize I am not sure how it behaves when a core system setting is updated.
The timezone is an openHAB system configuration setting that the user can update, using Paper UI for example. When this setting is updated, the bundle (which one exactly ?) is updated. As we have an OSGi reference to this service in the binding thing handler factory component, what will happen ? Will the handler factory component be restarted with the updated reference ? If true, all thing handlers will be created again and my solution is ok. Passing the TimeZoneProvider object to the thing handler will make no change.
In case the setting change will have no impact on the binding handler factory component (no deactivate/activate), your remark will be valid. But in this case, I don't understand how OSGi components are informed of changes in referenced components.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not clear for me in fact.
I should test a change of timezone and see the impact on the thing handler factory and thing handlers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, tested now. In fact, changing the timezone setting has no direct impact on the thing handler factory or thing handler. Nothing is restarted. So my solution is not good.
If I pass the TimeZoneProvider as parameter to the thing handler, it looks like it is correctly updated in the thing handler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@TravisBuddy
Copy link

Travis tests were successful

Hey @lolodomo,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

Copy link
Contributor

@cpmeister cpmeister left a comment

Choose a reason for hiding this comment

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

LGTM

@cpmeister cpmeister added the enhancement An enhancement or new feature for an existing add-on label Jun 9, 2020
@cpmeister cpmeister merged commit 52fb5d9 into openhab:2.5.x Jun 9, 2020
@cpmeister cpmeister added this to the 2.5.6 milestone Jun 9, 2020
@lolodomo lolodomo deleted the wu_timezoneprovider branch June 9, 2020 16:38
knikhilwiz pushed a commit to knikhilwiz/openhab2-addons that referenced this pull request Jul 12, 2020
…penhab#7878)

* [weatherunderground] Consider TimeZoneProvider to get the timezone

Also fix few warnings about null check
* TimeZoneProvider passed as parameter to the thing handler

Signed-off-by: Laurent Garnier <[email protected]>
CSchlipp pushed a commit to CSchlipp/openhab-addons that referenced this pull request Jul 26, 2020
…penhab#7878)

* [weatherunderground] Consider TimeZoneProvider to get the timezone

Also fix few warnings about null check
* TimeZoneProvider passed as parameter to the thing handler

Signed-off-by: Laurent Garnier <[email protected]>
Signed-off-by: CSchlipp <[email protected]>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
…penhab#7878)

* [weatherunderground] Consider TimeZoneProvider to get the timezone

Also fix few warnings about null check
* TimeZoneProvider passed as parameter to the thing handler

Signed-off-by: Laurent Garnier <[email protected]>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
…penhab#7878)

* [weatherunderground] Consider TimeZoneProvider to get the timezone

Also fix few warnings about null check
* TimeZoneProvider passed as parameter to the thing handler

Signed-off-by: Laurent Garnier <[email protected]>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
…penhab#7878)

* [weatherunderground] Consider TimeZoneProvider to get the timezone

Also fix few warnings about null check
* TimeZoneProvider passed as parameter to the thing handler

Signed-off-by: Laurent Garnier <[email protected]>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
…penhab#7878)

* [weatherunderground] Consider TimeZoneProvider to get the timezone

Also fix few warnings about null check
* TimeZoneProvider passed as parameter to the thing handler

Signed-off-by: Laurent Garnier <[email protected]>
DaanMeijer pushed a commit to DaanMeijer/openhab-addons that referenced this pull request Sep 1, 2020
…penhab#7878)

* [weatherunderground] Consider TimeZoneProvider to get the timezone

Also fix few warnings about null check
* TimeZoneProvider passed as parameter to the thing handler

Signed-off-by: Laurent Garnier <[email protected]>
Signed-off-by: Daan Meijer <[email protected]>
markus7017 pushed a commit to markus7017/openhab-addons that referenced this pull request Sep 19, 2020
…penhab#7878)

* [weatherunderground] Consider TimeZoneProvider to get the timezone

Also fix few warnings about null check
* TimeZoneProvider passed as parameter to the thing handler

Signed-off-by: Laurent Garnier <[email protected]>
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