Skip to content

Bug in Weather Units for Broadcasted Notification#3519

Merged
rejas merged 13 commits into
MagicMirrorOrg:developfrom
skpanagiotis:bug-weather-units
Aug 18, 2024
Merged

Bug in Weather Units for Broadcasted Notification#3519
rejas merged 13 commits into
MagicMirrorOrg:developfrom
skpanagiotis:bug-weather-units

Conversation

@skpanagiotis

@skpanagiotis skpanagiotis commented Aug 4, 2024

Copy link
Copy Markdown
Contributor

This PR resolve Issue number #3419 .

I have added the method convertWeatherObjectToImperial() which converts the units of the notificationPayload to imperial if needed, in order to pass the object in sendNotification().

@khassel

khassel commented Aug 4, 2024

Copy link
Copy Markdown
Collaborator

Thanks! Can you please add an entry to the CHANGELOG.md file? (otherwise the tests will fail ...)

@khassel

khassel commented Aug 4, 2024

Copy link
Copy Markdown
Collaborator

if you need help to fix the lint errors in the failed test let me know

@sdetweil

sdetweil commented Aug 4, 2024

Copy link
Copy Markdown
Collaborator

Some of the problem is doing npm run install-mm doesn’t install the git commit hooks

@skpanagiotis

Copy link
Copy Markdown
Contributor Author

I resolve eslint errors.
Is there a possibility that the failed tests are due to my code?

@khassel

khassel commented Aug 5, 2024

Copy link
Copy Markdown
Collaborator

from the test: "Error: Uncaught [SyntaxError: Identifier 'WeatherObject' has already been declared]\n"

yes, you introduced const WeatherObject = require("./weatherobject"); but in the tests we have in file weather_object_spec.js the same variable name const WeatherObject = require ... so renaming one of them should solve this

@khassel

khassel commented Aug 5, 2024

Copy link
Copy Markdown
Collaborator

looks like a typo:

convertPrecipitationToInch vs. this.convertPerticipationToInch

@skpanagiotis

Copy link
Copy Markdown
Contributor Author

Thanks very much for your time and help, my mistake is that I skipped running tests, because I was working on Windows system.

@khassel khassel requested a review from rejas August 5, 2024 20:38
Comment thread modules/default/weather/weatherutils.js Outdated
Comment thread modules/default/weather/weatherutils.js Outdated
@khassel khassel requested a review from rejas August 5, 2024 21:53
Comment thread modules/default/weather/weatherutils.js Outdated
*/
convertPrecipitationToInch (value, valueUnit) {
if (valueUnit && valueUnit.toLowerCase() === "cm") return value * 0.3937007874;
else return value * 0.03937007874;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this else code does the same as the if part?
and why not use the convertPrecipitationUnit method?

@skpanagiotis skpanagiotis Aug 6, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the code inside if converts cm to inch and the code inside else converts mm to inch.
The reason that I added convertPrecipitationToInch () method is that convertPrecipitationUnit() returns a string, and I think that maybe we need the raw value of precipitation.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

sorry for late reply and my first wrong response...

i get your point, will add a small improvement myself and approve

Comment thread modules/default/weather/weatherutils.js Outdated
*/
convertPrecipitationToInch (value, valueUnit) {
if (valueUnit && valueUnit.toLowerCase() === "cm") return value * 0.3937007874;
else return value * 0.03937007874;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

sorry for late reply and my first wrong response...

i get your point, will add a small improvement myself and approve

@rejas rejas merged commit 5673678 into MagicMirrorOrg:develop Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants