85 Commits

Author SHA1 Message Date
OWL4C
eceec8285d
Adding experimental UV Index support for weather module (#3108)
This pr adds (config.js toggleable) showUV_Index to the hourly and
current weather modules, with right now only openmeteo configured to
supply the data. Other providers could have support too by adding
`uv_index` to current and hourly.

For example the current weather looks like
![image](https://github.com/MichMich/MagicMirror/assets/124401812/00fdf5db-c0d5-4797-9a31-1d72dd970d26)
positioned after sunset in the top row.



The following "hacks" are included and could be fixed to make it
cleaner, but the functionality is wanted and it works without problem.
- To hide entries where the UV Index is 0 i added an if statement to the
`hourly.njk` which is not how precipitation is handled.
The following are minor things that might not need fixing:
- The forecast option does not have UV support. This might not be
relevant since UV changes throughout the day but i tried to implement a
"max_UV" to openmeteo.js, but am not confident enough in JS to
accomplish that.
- The UV Icon is wi-hot and manually added to the `.njk`'s. This could
be made changeable by a config but does not seem relevant since wi-hot
is not used by anything else as far as i can tell.

---------

Co-authored-by: veeck <michael@veeck.de>
2023-05-22 10:57:48 +02:00
Veeck
7e58b38ddf
Add no-param-reassign from eslint (#3089)
While waiting for the easterbunny I cleaned up some bad coding practice
:-)

Very open for comments especially regarding the places I commented
myself...

---------

Co-authored-by: veeck <michael@veeck.de>
2023-04-16 17:38:39 +02:00
Veeck
32192d1698
Refactor formatTime into util class (#3073)
While looking at https://github.com/MichMich/MagicMirror/pull/3070 I
noticed that the weather and clock module do some formatTime stuff, so
why not use a common function for that?

---------

Co-authored-by: veeck <michael@veeck.de>
2023-04-07 23:11:54 +02:00
Kristjan ESPERANTO
d276a7ddb9
Use template literals instead of string concatenation (#3066)
We have used it inconsistently till now. Template literals are more
modern and easier to maintain in my opinion.

Because that's a large amount of changes, here's a way to reproduce it:
I added the rule `"prefer-template": "error"` to the `.eslintrc.json`
and did an autofix. Since this caused a new problem in line 409 of
`newsfeed.js`, I reversed it in that line and also removed the rule from
the eslint config file.

The rule is described here:
https://eslint.org/docs/latest/rules/prefer-template

Note: I've played around with some other linter rules as well, and some
seem to point to some specific, non-cosmetic, issues. But before I dive
even deeper and then introduce even bigger and hardly understandable
changes at once, I thought I'd start with this simple cosmetic rule.
2023-03-19 14:32:23 +01:00
Magnus
bf279d9a57
Tidy up precipitation (#3023)
Fixes #2953

This is an attempt to fix the issue with precipitation amount and
percentage mixup. I have created a separate
`precipitationPercentage`-variable where the probability of rain can be
stored.

The config options now has the old `showPrecipitationAmount` in addition
to a new setting: `showPrecipitationProbability` (shows the likelihood
of rain).

<details>
  <summary>Examples</summary>
  
  ### Yr

I tested the Yr weather provider for a Norwegian city Bergen that has a
lot of rain. I have removed properties that are irrelevant for this demo
from the config-samples below.

Config:
  ```js
{
	module: "weather",
	config: {
			weatherProvider: "yr",
			type: "current",
			showPrecipitationAmount: true,
			showPrecipitationProbability: true
	}
},
{
	module: "weather",
	config: {
			weatherProvider: "yr",
			type: "hourly",
			showPrecipitationAmount: true,
			showPrecipitationProbability: true
	}
},
{
	module: "weather",
	config: {
			weatherProvider: "yr",
			type: "daily",
			showPrecipitationAmount: true,
			showPrecipitationProbability: true
	}
}
  ```

Result:<br/>
<img width="444" alt="screenshot"
src="https://user-images.githubusercontent.com/34011212/216775423-4e37345c-f915-47e5-8551-7c544ebd24b1.png">

</details>

---------

Co-authored-by: Magnus Marthinsen <magmar@online.no>
Co-authored-by: Veeck <github@veeck.de>
2023-02-04 19:02:55 +01:00
Veeck
6e80e5a295
Add option to show hourly forecast in increments (#2998)
Adds new config option to show weather forecast for every X hour
(default value is 1 which reflects the current behaviour)
Also adds tests for hourly forecast
Fixes #2996

Co-authored-by: veeck <michael@veeck.de>
2023-01-10 18:55:07 +01:00
Magnus
bd0b3c00ad
New weather provider: Yr.no (#2948)
# Added Yr.no as a weather provider

Yr.no is a free Norwegian weather service. The configuration is quite
simple:
```js
{
    weatherProvider: "yr",
    lat: 59.9171,
    lon: 10.7276,
    altitude: 30
}
```
The latitude and longitude cannot have more than 4 decimals, but that
should be plenty. To quote yr: "There is no need to ask for weather
forecasts with nanometer precision!". The altitude should be meters
above sea level and defaults to 0. If `type` is set to `current` the
symbol can display the next 1, 6 or 12 hours by setting
`currentForecastHours` (default is 1).

It states in [Getting
started-guide](https://developer.yr.no/doc/GettingStarted/) that users
of the API should cache the results and use the `Expires`-header to know
when to ask for new data. By using the `If-Modified-Since`-header we can
avoid downloading the same data over and over again. I chose not to
override the `User-Agent`-header set in
[`server.js`](https://github.com/MichMich/MagicMirror/blob/a328ce5/js/server.js#L97)
even though it does not comply with [the terms of
service](https://developer.yr.no/doc/TermsOfService/). It currently
works with the default header, and by searching the web for MagicMirror
the GitHub-repo should be easy to find without an explicit link.

I also had to make some minor changes to `server.js` and
`weatherprovider.js` to be able to send and return HTTP headers. To
handle the HTTP 304 response without body I chose to return `undefined`
so we easily can use the response as a condition: `if (response) ...`.

The documentation for the API is available here:
- [API Reference overview](https://api.met.no/weatherapi/)
-
[Locationforecast](https://api.met.no/weatherapi/locationforecast/2.0/)
- Used to get the weather forecast
- [Sunrise](https://api.met.no/weatherapi/sunrise/2.0/documentation) -
used to find sunrise and sunset times

Co-authored-by: Veeck <github@veeck.de>
2022-11-08 06:18:47 +01:00
Veeck
c191ff0032
Refactor common weather methods into utils class (#2958)
Co-authored-by: veeck <michael@veeck.de>
2022-10-28 19:56:55 +02:00
Veeck
2d3940a4ff
Use metric units internally in all weatherproviders (#2849)
So finally I think this refactorin is ready to be reviewed :-)

DONE:
- [x] Removed all conversion functions for wind and temperature from
specific weatherproviders
- [x] Use internally only metric units: celsius for temperature, meters
per seconds for wind
- [x] Convert temp and wind into the configured units when displaying
data on the UI
- [x] look how beaufort calculation uses metrics, added knots as new
windunit
- [x] add more e2e tests 

Checked providers:
- [x] Darksky
- [x] EnvCanada
- [x] OpenWeatherMap
- [x] SMHI provider 
- [x] UK Met Office
- [x] UK Met Office DataHub
- [x] WeatherBit
- [x] WeatherFlow
- [x] WeatherGov

TODO in different tickets:
- check weatherproviders for usage of weatherEndpoint (as seen in
https://github.com/MichMich/MagicMirror-Documentation/issues/131) -> see
#2926
- cleanup precipations -> #2953

Co-authored-by: veeck <michael@veeck.de>
2022-10-24 19:41:34 +02:00
eouia
1d90c5e1fe Add JSDoc description 2022-04-26 17:37:23 +02:00
eouia
038b6765e7 Change property name clearly 2022-04-26 14:52:05 +02:00
eouia
df0f048ecc Added outgoing notification 2022-04-26 13:55:39 +02:00
Kristjan SCHMIDT
a5668b1b99 Magic Mirror -> MagicMirror²
Consistent spelling
2022-01-26 23:09:26 +01:00
Sean Scott
0f596d5620
Update weather.js
Set absoluteDates default to false
2022-01-02 14:45:24 -07:00
rejas
745a5f0376 Move ignoreToday logic into template to fix undefined forecast 2021-08-01 09:39:07 +02:00
rejas
1b42dc779b Run prettier again 2021-05-29 16:11:39 +02:00
Michael Teeuw
49d2d8c9d0
Merge pull request #2574 from daniel-windsor/forecase-ignore-today 2021-05-29 13:59:55 +02:00
Daniel Windsor
fc5a438cdc Add flag that removes today entry in forecast 2021-05-26 21:45:24 +12:00
rejas
2ababa521d Use es6 notation in weather module and ukmet provider 2021-04-17 16:29:38 +02:00
buxxi
3c4d7a33e0 Fixing code style issue with no return before default 2021-01-23 12:07:10 +01:00
buxxi
41508931be Moving default values regarding specific providers into the providers themselves 2021-01-23 11:21:56 +01:00
buxxi
e2cfa24686 make weatherprovider have a method for hourly fetching instead of a generic weatherData 2021-01-23 10:45:55 +01:00
buxxi
d48113f2d9 Moving openweathermap specific check for hourly into its provider and make invalid types fail nicer 2021-01-23 10:13:41 +01:00
veeck
90f07295b1 Add extra check for currentweather 2021-01-17 15:00:34 +01:00
rejas
42cac81953 Fix tests 2021-01-15 23:12:44 +01:00
rejas
e0d43a4c1e Add new Event CURRENTWEATHER_TYPE
- send it from the weather and currentweather module
- use it in the compliments module directly instead of the data
2021-01-15 21:47:14 +01:00
Ashish Tank
774b86c7dc Code cleanup for feels like translation 2021-01-10 17:37:10 +01:00
Michael Teeuw
6f0f75cf27
Merge pull request #2388 from drewski3420/no_negative_zero
No negative zero
2021-01-07 12:41:30 +01:00
Michael Teeuw
7b36bb025a Improve readabiliy. 2021-01-07 11:51:10 +01:00
Ashish Tank
4a341b381e Added support for variables in nunjucks templates for translate filter 2020-12-31 18:58:21 +01:00
drewski3420@gmail.com
e51f6597ed This change prevents returning '-0' (negative zero) when roundTemp is true. 2020-12-30 09:03:19 -05:00
Michael Teeuw
be0c8f4f16 Prettier fix. 2020-12-08 16:01:19 +01:00
Michael Teeuw
46fd2de315
Merge branch 'develop' into develop 2020-12-08 15:53:21 +01:00
Aurélien Veillard
1460f002ab Add new parameter "useKmh" to weather module
Add new parameter "useKmh" to weather module for displaying wind speed as km/h instead of m/s when windUnits is set to metric.
2020-11-08 14:01:02 +01:00
Aurélien Veillard
198525f2ce Weather config enhancement
Add new parameter 'useKmh' to display wind speed in km/h instead of m/s.
2020-11-07 09:54:13 +01:00
Michael Teeuw
207a9ba723
Merge branch 'develop' into bryanzzhu-weather 2020-09-18 12:15:44 +02:00
rejas
86fb1b938b Check for undefined header data in weather modules 2020-08-13 21:51:18 +02:00
Bryan Zhu
a4d73e2a67 amended code according to pull request reviews 2020-08-01 17:39:58 -04:00
Bryan Zhu
b1a67d1fc5 integrated onecall usage into existing types 2020-08-01 02:59:08 -04:00
Bryan Zhu
9d22420027 Merge branch 'develop' of https://github.com/MichMich/MagicMirror into bryanzzhu-weather 2020-07-08 23:06:29 -04:00
Michael Teeuw
3282ed4fea Add TODO 2020-07-04 21:49:14 +02:00
Michael Teeuw
bd0f707aed Add changelog. 2020-07-04 21:40:31 +02:00
Bryan Zhu
85ed1b85ae added functional current, hourly, and daily forecasts via OpenWeatherMap One Call API 2020-07-01 05:08:04 -04:00
Bryan Zhu
ffbf0804d9 added default values for lat and lon 2020-06-30 12:41:14 -04:00
Bryan Zhu
ca0b89ecd3 backtracked apiKey change to appid 2020-06-30 12:36:23 -04:00
Bryan Zhu
dc9d6f6b79 fixed minor typo (apiKey vs. appid) 2020-06-30 12:29:00 -04:00
Bryan Zhu
a4df38d963 fixed config parameter typo 2020-06-30 04:18:03 -04:00
Bryan Zhu
4a162543f6 added OpenWeatherMap One Call API function to default Weather module, added wDataHourly type 2020-06-30 02:40:41 -04:00
CreepinJesus
4339cdd8a4
Included check for Met Office DataHub provider.
The new Met Office provider also returns precipitation as a probability percentage.
2020-06-28 11:00:10 +01:00
Kristof Rado
6f3b87cfd1 Merge branch 'develop' into weather-module 2020-05-29 23:56:09 +02:00