mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
commit
cd06d8c63a
@ -1,6 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "7"
|
||||
- "8"
|
||||
before_script:
|
||||
- yarn danger ci
|
||||
- npm install grunt-cli -g
|
||||
|
42
CHANGELOG.md
42
CHANGELOG.md
@ -5,6 +5,46 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
---
|
||||
|
||||
## [2.7.0] - Unreleased
|
||||
|
||||
*This release is scheduled to be released on 2019-04-01.*
|
||||
|
||||
ℹ️ **Note:** This update uses new dependencies. Please update using the following command: `git pull && npm install`. If you are having issues running Electron, make sure your [Raspbian is up to date](https://www.raspberrypi.org/documentation/raspbian/updating.md).
|
||||
|
||||
### Added
|
||||
- Italian translation for "Feels"
|
||||
- Disabled the screensaver on raspbian with installation script
|
||||
- Added option to truncate the number of vertical lines a calendar item can span if `wrapEvents` is enabled.
|
||||
- Added autoLocation options for weather forcast and current weather modules.
|
||||
- Added autoTimezone option for the default clock module.
|
||||
- Danish translation for "Feels" and "Weeks"
|
||||
|
||||
### Updated
|
||||
- Bumped the Electron dependency to v3.0.13 to support the most recent Raspbian. [#1500](https://github.com/MichMich/MagicMirror/issues/1500)
|
||||
|
||||
### Fixed
|
||||
- Fixed temperature displays in currentweather and weatherforecast modules [#1503](https://github.com/MichMich/MagicMirror/issues/1503), [#1511](https://github.com/MichMich/MagicMirror/issues/1511).
|
||||
- Fixed unhandled error on bad git data in updatenotiifcation module [#1285](https://github.com/MichMich/MagicMirror/issues/1285).
|
||||
- Weather forecast now works with openweathermap in new weather module. Daily data are displayed, see issue [#1504](https://github.com/MichMich/MagicMirror/issues/1504).
|
||||
- Fixed analogue clock border display issue where non-black backgrounds used (previous fix for issue 611)
|
||||
- Fixed compatibility issues caused when modules request different versions of Font Awesome, see issue [#1522](https://github.com/MichMich/MagicMirror/issues/1522). MagicMirror now uses [Font Awesome 5 with v4 shims included for backwards compatibility](https://fontawesome.com/how-to-use/on-the-web/setup/upgrading-from-version-4#shims).
|
||||
- Installation script problems with raspbian
|
||||
- Calendar: only show repeating count if the event is actually repeating [#1534](https://github.com/MichMich/MagicMirror/pull/1534)
|
||||
- Calendar: Fix exdate handling when multiple values are specified (comma separated)
|
||||
- Fix null dereference in moduleNeedsUpdate when the module isn't visible
|
||||
|
||||
### New weather module
|
||||
- Fixed weather forecast table display [#1499](https://github.com/MichMich/MagicMirror/issues/1499).
|
||||
- Dimmed loading indicator for weather forecast.
|
||||
- Implemented config option `decimalSymbol` [#1499](https://github.com/MichMich/MagicMirror/issues/1499).
|
||||
- Aligned indoor values in current weather vertical [#1499](https://github.com/MichMich/MagicMirror/issues/1499).
|
||||
- Added humidity support to nunjuck unit filter.
|
||||
- Do not display degree symbol for temperature in Kelvin [#1503](https://github.com/MichMich/MagicMirror/issues/1503).
|
||||
- Weather forecast now works with openweathermap for both, `/forecast` and `/forecast/daily`, in new weather module. If you use the `/forecast`-weatherEndpoint, the hourly data are converted to daily data, see issues [#1504](https://github.com/MichMich/MagicMirror/issues/1504), [#1513](https://github.com/MichMich/MagicMirror/issues/1513).
|
||||
- Added fade, fadePoint and maxNumberOfDays properties to the forecast mode [#1516](https://github.com/MichMich/MagicMirror/issues/1516)
|
||||
- Fixed Loading string and decimalSymbol string replace [#1538](https://github.com/MichMich/MagicMirror/issues/1538)
|
||||
- Show Snow amounts in new weather module [#1545](https://github.com/MichMich/MagicMirror/issues/1545)
|
||||
|
||||
## [2.6.0] - 2019-01-01
|
||||
|
||||
ℹ️ **Note:** This update uses new dependencies. Please update using the following command: `git pull && npm install`. If you are having issues updating, make sure you are running the latest version of Node.
|
||||
@ -12,6 +52,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
### ✨ Experimental ✨
|
||||
- New default [module weather](modules/default/weather). This module will eventually replace the current `currentweather` and `weatherforecast` modules. The new module is still pretty experimental, but it's included so you can give it a try and help us improve this module. Please give us you feedback using [this forum post](https://forum.magicmirror.builders/topic/9335/default-weather-module-refactoring).
|
||||
|
||||
A huge, huge, huge thanks to user @fewieden for all his hard work on the new `weather` module!
|
||||
|
||||
### Added
|
||||
- Possibility to add classes to the cell of symbol, title and time of the events of calendar.
|
||||
- Font-awesome 5, still has 4 for backwards compatibility.
|
||||
|
19
README.md
19
README.md
@ -7,7 +7,6 @@
|
||||
<a href="http://choosealicense.com/licenses/mit"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"></a>
|
||||
<a href="https://travis-ci.org/MichMich/MagicMirror"><img src="https://travis-ci.org/MichMich/MagicMirror.svg" alt="Travis"></a>
|
||||
<a href="https://snyk.io/test/github/MichMich/MagicMirror"><img src="https://snyk.io/test/github/MichMich/MagicMirror/badge.svg" alt="Known Vulnerabilities" data-canonical-src="https://snyk.io/test/github/MichMich/MagicMirror" style="max-width:100%;"></a>
|
||||
<a href="http://slack.magicmirror.builders"><img src="http://slack.magicmirror.builders:3000/badge.svg" alt="Slack Status"></a>
|
||||
</p>
|
||||
|
||||
**MagicMirror²** is an open source modular smart mirror platform. With a growing list of installable modules, the **MagicMirror²** allows you to convert your hallway or bathroom mirror into your personal assistant. **MagicMirror²** is built by the creator of [the original MagicMirror](http://michaelteeuw.nl/tagged/magicmirror) with the incredible help of a [growing community of contributors](https://github.com/MichMich/MagicMirror/graphs/contributors).
|
||||
@ -16,18 +15,22 @@ MagicMirror² focuses on a modular plugin system and uses [Electron](http://elec
|
||||
|
||||
## Table Of Contents
|
||||
|
||||
- [Table Of Contents](#table-of-contents)
|
||||
- [Installation](#installation)
|
||||
- [Raspberry Pi](#raspberry-pi)
|
||||
- [General](#general)
|
||||
- [Automatic Installation (Raspberry Pi only!)](#automatic-installation-raspberry-pi-only)
|
||||
- [Manual Installation](#manual-installation)
|
||||
- [Server Only](#server-only)
|
||||
- [Client Only](#client-only)
|
||||
- [Docker](#docker)
|
||||
- [Configuration](#configuration)
|
||||
- [Raspberry Specific](#raspberry-specific)
|
||||
- [General](#general)
|
||||
- [Modules](#modules)
|
||||
- [Updating](#updating)
|
||||
- [Known Issues](#known-issues)
|
||||
- [Community](#community)
|
||||
- [Contributing Guidelines](#contributing-guidelines)
|
||||
- [Enjoying MagicMirror? Consider a donation!](#enjoying-magicmirror-consider-a-donation)
|
||||
- [Manifesto](#manifesto)
|
||||
|
||||
## Installation
|
||||
@ -199,6 +202,16 @@ Please keep the following in mind:
|
||||
|
||||
Thanks for your help in making MagicMirror² better!
|
||||
|
||||
|
||||
## Enjoying MagicMirror? Consider a donation!
|
||||
|
||||
MagicMirror² is opensource and free. That doesn't mean we don't need any money.
|
||||
|
||||
Please consider a donation to help us cover the ongoing costs like webservers and email services.
|
||||
If we recieve enough donations we might even be able to free up some working hours and spend some extra time improving the MagicMirror² core.
|
||||
|
||||
To donate, please follow [this](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=G5D8E9MR5DTD2&source=url) link.
|
||||
|
||||
## Manifesto
|
||||
|
||||
A real Manifesto is still to be written. Till then, Michael's response on [one of the repository issues](https://github.com/MichMich/MagicMirror/issues/1174) gives a great summary:
|
||||
|
@ -47,7 +47,7 @@ sudo apt-get --assume-yes install curl wget git build-essential unzip || exit
|
||||
# Check if we need to install or upgrade Node.js.
|
||||
echo -e "\e[96mCheck current Node installation ...\e[0m"
|
||||
NODE_INSTALL=false
|
||||
if command_exists node; then
|
||||
if command_exists node && command_exists npm; then
|
||||
echo -e "\e[0mNode currently installed. Checking version number.";
|
||||
NODE_CURRENT=$(node -v)
|
||||
echo -e "\e[0mMinimum Node version: \e[1m$NODE_TESTED\e[0m"
|
||||
@ -152,9 +152,19 @@ fi
|
||||
read -p "Do you want use pm2 for auto starting of your MagicMirror (y/N)?" choice
|
||||
if [[ $choice =~ ^[Yy]$ ]]; then
|
||||
sudo npm install -g pm2
|
||||
sudo su -c "env PATH=$PATH:/usr/bin pm2 startup linux -u pi --hp /home/pi"
|
||||
pm2 start ~/MagicMirror/installers/pm2_MagicMirror.json
|
||||
pm2 save
|
||||
if [[ "$(ps --no-headers -o comm 1)" =~ systemd ]]; then #Checking for systemd
|
||||
sudo pm2 startup systemd -u pi --hp /home/pi
|
||||
else
|
||||
sudo su -c "env PATH=$PATH:/usr/bin pm2 startup linux -u pi --hp /home/pi"
|
||||
fi
|
||||
pm2 start ~/MagicMirror/installers/pm2_MagicMirror.json
|
||||
pm2 save
|
||||
fi
|
||||
# Disable Screensaver
|
||||
read -p "Do you want to disable the screen saver? (y/N)?" choice
|
||||
if [[ $choice =~ ^[Yy]$ ]]; then
|
||||
sudo su -c "echo -e '@xset s noblank\n@xset s off\n@xset -dpms' >> /etc/xdg/lxsession/LXDE-pi/autostart"
|
||||
export DISPLAY=:0; xset s noblank;xset s off;xset -dpms
|
||||
fi
|
||||
|
||||
echo " "
|
||||
|
@ -173,6 +173,10 @@ var MM = (function() {
|
||||
*/
|
||||
var moduleNeedsUpdate = function(module, newHeader, newContent) {
|
||||
var moduleWrapper = document.getElementById(module.identifier);
|
||||
if (moduleWrapper === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var contentWrapper = moduleWrapper.getElementsByClassName("module-content");
|
||||
var headerWrapper = moduleWrapper.getElementsByClassName("module-header");
|
||||
|
||||
|
@ -33,8 +33,8 @@ Therefore **we highly recommend you to include the following information in your
|
||||
|
||||
- A high quality screenshot of your working module
|
||||
- A short, one sentence, clear description what it does (duh!)
|
||||
- What external API's it depend on, including web links to those
|
||||
- Wheteher the API/request require a key and the user limitations of those. (Is it free?)
|
||||
- What external API's it depends upon, including web links to those
|
||||
- Whether the API/request require a key and the user limitations of those. (Is it free?)
|
||||
|
||||
Surely this also help you get better recognition and feedback for your work.
|
||||
|
||||
@ -46,8 +46,8 @@ A module can be placed in one single folder. Or multiple modules can be grouped
|
||||
|
||||
### Files
|
||||
- **modulename/modulename.js** - This is your core module script.
|
||||
- **modulename/node_helper.js** - This is an optional helper that will be loaded by the node script. The node helper and module script can communicate with each other using an intergrated socket system.
|
||||
- **modulename/public** - Any files in this folder can be accesed via the browser on `/modulename/filename.ext`.
|
||||
- **modulename/node_helper.js** - This is an optional helper that will be loaded by the node script. The node helper and module script can communicate with each other using an integrated socket system.
|
||||
- **modulename/public** - Any files in this folder can be accessed via the browser on `/modulename/filename.ext`.
|
||||
- **modulename/anyfileorfolder** Any other file or folder in the module folder can be used by the core module script. For example: *modulename/css/modulename.css* would be a good path for your additional module styles.
|
||||
|
||||
## The Core module file: modulename.js
|
||||
@ -89,7 +89,7 @@ After the module is initialized, the module instance has a few available module
|
||||
| `this.data` | Object | The data object contain additional metadata about the module instance. (See below) |
|
||||
|
||||
|
||||
The `this.data` data object contain the follwoing metadata:
|
||||
The `this.data` data object contain the following metadata:
|
||||
- `data.classes` - The classes which are added to the module dom wrapper.
|
||||
- `data.file` - The filename of the core module file.
|
||||
- `data.path` - The path of the module folder.
|
||||
@ -98,7 +98,7 @@ The `this.data` data object contain the follwoing metadata:
|
||||
|
||||
|
||||
#### `defaults: {}`
|
||||
Any properties defined in the defaults object, will be merged with the module config as defined in the user's config.js file. This is the best place to set your modules's configuration defaults. Any of the module configuration properties can be accessed using `this.config.propertyName`, but more about that later.
|
||||
Any properties defined in the defaults object, will be merged with the module config as defined in the user's config.js file. This is the best place to set your modules' configuration defaults. Any of the module configuration properties can be accessed using `this.config.propertyName`, but more about that later.
|
||||
|
||||
#### `requiresVersion:`
|
||||
|
||||
@ -134,7 +134,7 @@ loaded: function(callback) {
|
||||
````
|
||||
|
||||
#### `start()`
|
||||
This method is called when all modules are loaded an the system is ready to boot up. Keep in mind that the dom object for the module is not yet created. The start method is a perfect place to define any additional module properties:
|
||||
This method is called when all modules are loaded and the system is ready to boot up. Keep in mind that the dom object for the module is not yet created. The start method is a perfect place to define any additional module properties:
|
||||
|
||||
**Example:**
|
||||
````javascript
|
||||
@ -161,7 +161,7 @@ getScripts: function() {
|
||||
}
|
||||
|
||||
````
|
||||
**Note:** If a file can not be loaded, the boot up of the mirror will stall. Therefore it's advised not to use any external urls.
|
||||
**Note:** If a file can not be loaded, the boot up of the mirror will stall. Therefore, it's advised not to use any external urls.
|
||||
|
||||
|
||||
#### `getStyles()`
|
||||
@ -174,14 +174,14 @@ The getStyles method is called to request any additional stylesheets that need t
|
||||
getStyles: function() {
|
||||
return [
|
||||
'script.css', // will try to load it from the vendor folder, otherwise it will load is from the module folder.
|
||||
'font-awesome.css', // this file is available in the vendor folder, so it doesn't need to be avialable in the module folder.
|
||||
'font-awesome.css', // this file is available in the vendor folder, so it doesn't need to be available in the module folder.
|
||||
this.file('anotherfile.css'), // this file will be loaded straight from the module folder.
|
||||
'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css', // this file will be loaded from the bootstrapcdn servers.
|
||||
]
|
||||
}
|
||||
|
||||
````
|
||||
**Note:** If a file can not be loaded, the boot up of the mirror will stall. Therefore it's advised not to use any external urls.
|
||||
**Note:** If a file can not be loaded, the boot up of the mirror will stall. Therefore, it's advised not to use any external URLs.
|
||||
|
||||
#### `getTranslations()`
|
||||
**Should return: Dictionary**
|
||||
@ -239,7 +239,7 @@ That MagicMirror core has the ability to send notifications to modules. Or even
|
||||
|
||||
- `notification` - String - The notification identifier.
|
||||
- `payload` - AnyType - The payload of a notification.
|
||||
- `sender` - Module - The sender of the notification. If this argument is `undefined`, the sender of the notififiction is the core system.
|
||||
- `sender` - Module - The sender of the notification. If this argument is `undefined`, the sender of the notification is the core system.
|
||||
|
||||
**Example:**
|
||||
````javascript
|
||||
@ -346,7 +346,7 @@ Possible configurable options:
|
||||
- `lockString` - String - When setting lock string, the module can not be shown without passing the correct lockstring. This way (multiple) modules can prevent a module from showing. It's considered best practice to use your modules identifier as the locksString: `this.identifier`. See *visibility locking* below.
|
||||
|
||||
|
||||
**Note 1:** If the hide animation is canceled, for instance because the show method is called before the hide animation was finished, the callback will not be called.<br>
|
||||
**Note 1:** If the hide animation is cancelled, for instance because the show method is called before the hide animation was finished, the callback will not be called.<br>
|
||||
**Note 2:** If the hide animation is hijacked (an other method calls hide on the same module), the callback will not be called.<br>
|
||||
**Note 3:** If the dom is not yet created, the hide method won't work. Wait for the `DOM_OBJECTS_CREATED` [notification](#notificationreceivednotification-payload-sender).
|
||||
|
||||
@ -371,7 +371,7 @@ Possible configurable options:
|
||||
|
||||
(*Introduced in version: 2.1.0.*)
|
||||
|
||||
Visiblity locking helps the module system to prevent unwanted hide/show actions. The following scenario explains the concept:
|
||||
Visibility locking helps the module system to prevent unwanted hide/show actions. The following scenario explains the concept:
|
||||
|
||||
**Module B asks module A to hide:**
|
||||
````javascript
|
||||
@ -436,7 +436,7 @@ If no translation is found, a fallback will be used. The fallback sequence is as
|
||||
- 4. Translation as defined in core translation file of the fallback language (the first defined core translation file).
|
||||
- 5. The key (identifier) of the translation.
|
||||
|
||||
When adding translations to your module, it's a good idea to see if an apropriate translation is already available in the [core translation files](https://github.com/MichMich/MagicMirror/tree/master/translations). This way, your module can benefit from the existing translations.
|
||||
When adding translations to your module, it's a good idea to see if an appropriate translation is already available in the [core translation files](https://github.com/MichMich/MagicMirror/tree/master/translations). This way, your module can benefit from the existing translations.
|
||||
|
||||
**Example:**
|
||||
````javascript
|
||||
@ -490,7 +490,7 @@ this.translate("RUNNING", {
|
||||
)}); // Will return a translated string for the identifier RUNNING, replacing `{timeUntilEnd}` with the contents of the variable `timeUntilEnd` in the order that translator intended. (has a fallback)
|
||||
````
|
||||
|
||||
**Example swedish .json file that does not have the variable in it:**
|
||||
**Example Swedish .json file that does not have the variable in it:**
|
||||
````javascript
|
||||
{
|
||||
"RUNNING": "Slutar",
|
||||
|
@ -32,6 +32,7 @@ The following properties can be configured:
|
||||
| `defaultSymbol` | The default symbol. <br><br> **Possible values:** See [Font Awsome](http://fontawesome.io/icons/) website. <br> **Default value:** `calendar`
|
||||
| `maxTitleLength` | The maximum title length. <br><br> **Possible values:** `10` - `50` <br> **Default value:** `25`
|
||||
| `wrapEvents` | Wrap event titles to multiple lines. Breaks lines at the length defined by `maxTitleLength`. <br><br> **Possible values:** `true` or `false` <br> **Default value:** `false`
|
||||
| `maxTitleLines` | The maximum number of lines a title will wrap vertically before being cut (Only enabled if `wrapEvents` is also enabled). <br><br> **Possible values:** `0` - `10` <br> **Default value:** `3`
|
||||
| `fetchInterval` | How often does the content needs to be fetched? (Milliseconds) <br><br> **Possible values:** `1000` - `86400000` <br> **Default value:** `300000` (5 minutes)
|
||||
| `animationSpeed` | Speed of the update animation. (Milliseconds) <br><br> **Possible values:** `0` - `5000` <br> **Default value:** `2000` (2 seconds)
|
||||
| `fade` | Fade the future events to black. (Gradient) <br><br> **Possible values:** `true` or `false` <br> **Default value:** `true`
|
||||
|
@ -19,6 +19,7 @@ Module.register("calendar", {
|
||||
defaultRepeatingCountTitle: "",
|
||||
maxTitleLength: 25,
|
||||
wrapEvents: false, // wrap events to multiple lines breaking at maxTitleLength
|
||||
maxTitleLines: 3,
|
||||
fetchInterval: 5 * 60 * 1000, // Update every 5 minutes.
|
||||
animationSpeed: 2000,
|
||||
fade: true,
|
||||
@ -51,7 +52,7 @@ Module.register("calendar", {
|
||||
|
||||
// Define required scripts.
|
||||
getStyles: function () {
|
||||
return ["calendar.css", "font-awesome5.css", "font-awesome5.v4shims.css"];
|
||||
return ["calendar.css", "font-awesome.css"];
|
||||
},
|
||||
|
||||
// Define required scripts.
|
||||
@ -220,7 +221,7 @@ Module.register("calendar", {
|
||||
var titleWrapper = document.createElement("td"),
|
||||
repeatingCountTitle = "";
|
||||
|
||||
if (this.config.displayRepeatingCountTitle) {
|
||||
if (this.config.displayRepeatingCountTitle && event.firstYear !== undefined) {
|
||||
|
||||
repeatingCountTitle = this.countTitleForUrl(event.url);
|
||||
|
||||
@ -584,9 +585,10 @@ Module.register("calendar", {
|
||||
* @param {string} string Text string to shorten
|
||||
* @param {number} maxLength The max length of the string
|
||||
* @param {boolean} wrapEvents Wrap the text after the line has reached maxLength
|
||||
* @param {number} maxTitleLines The max number of vertical lines before cutting event title
|
||||
* @returns {string} The shortened string
|
||||
*/
|
||||
shorten: function (string, maxLength, wrapEvents) {
|
||||
shorten: function (string, maxLength, wrapEvents, maxTitleLines) {
|
||||
if (typeof string !== "string") {
|
||||
return "";
|
||||
}
|
||||
@ -595,12 +597,21 @@ Module.register("calendar", {
|
||||
var temp = "";
|
||||
var currentLine = "";
|
||||
var words = string.split(" ");
|
||||
var line = 0;
|
||||
|
||||
for (var i = 0; i < words.length; i++) {
|
||||
var word = words[i];
|
||||
if (currentLine.length + word.length < (typeof maxLength === "number" ? maxLength : 25) - 1) { // max - 1 to account for a space
|
||||
currentLine += (word + " ");
|
||||
} else {
|
||||
line++;
|
||||
if (line > maxTitleLines - 1) {
|
||||
if (i < words.length) {
|
||||
currentLine += "…";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (currentLine.length > 0) {
|
||||
temp += (currentLine + "<br>" + word + " ");
|
||||
} else {
|
||||
@ -651,7 +662,7 @@ Module.register("calendar", {
|
||||
title = title.replace(needle, replacement);
|
||||
}
|
||||
|
||||
title = this.shorten(title, this.config.maxTitleLength, this.config.wrapEvents);
|
||||
title = this.shorten(title, this.config.maxTitleLength, this.config.wrapEvents, this.config.maxTitleLines);
|
||||
return title;
|
||||
},
|
||||
|
||||
|
78
modules/default/calendar/vendor/ical.js/ical.js
vendored
78
modules/default/calendar/vendor/ical.js/ical.js
vendored
@ -80,16 +80,45 @@
|
||||
}
|
||||
}
|
||||
|
||||
var addTZ = function(dt, name, params){
|
||||
var addTZ = function(dt, params){
|
||||
var p = parseParams(params);
|
||||
|
||||
if (params && p){
|
||||
dt[name].tz = p.TZID
|
||||
if (params && p && dt){
|
||||
dt.tz = p.TZID
|
||||
}
|
||||
|
||||
return dt
|
||||
}
|
||||
|
||||
var parseTimestamp = function(val){
|
||||
//typical RFC date-time format
|
||||
var comps = /^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})(Z)?$/.exec(val);
|
||||
if (comps !== null) {
|
||||
if (comps[7] == 'Z'){ // GMT
|
||||
return new Date(Date.UTC(
|
||||
parseInt(comps[1], 10),
|
||||
parseInt(comps[2], 10)-1,
|
||||
parseInt(comps[3], 10),
|
||||
parseInt(comps[4], 10),
|
||||
parseInt(comps[5], 10),
|
||||
parseInt(comps[6], 10 )
|
||||
));
|
||||
// TODO add tz
|
||||
} else {
|
||||
return new Date(
|
||||
parseInt(comps[1], 10),
|
||||
parseInt(comps[2], 10)-1,
|
||||
parseInt(comps[3], 10),
|
||||
parseInt(comps[4], 10),
|
||||
parseInt(comps[5], 10),
|
||||
parseInt(comps[6], 10)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var dateParam = function(name){
|
||||
return function(val, params, curr){
|
||||
|
||||
@ -108,37 +137,24 @@
|
||||
comps[3]
|
||||
);
|
||||
|
||||
return addTZ(curr, name, params);
|
||||
curr[name] = addTZ(curr[name], params);
|
||||
return curr;
|
||||
}
|
||||
}
|
||||
|
||||
curr[name] = []
|
||||
val.split(',').forEach(function(val){
|
||||
var newDate = parseTimestamp(val);
|
||||
curr[name].push(addTZ(newDate, params));
|
||||
});
|
||||
|
||||
//typical RFC date-time format
|
||||
var comps = /^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})(Z)?$/.exec(val);
|
||||
if (comps !== null) {
|
||||
if (comps[7] == 'Z'){ // GMT
|
||||
curr[name] = new Date(Date.UTC(
|
||||
parseInt(comps[1], 10),
|
||||
parseInt(comps[2], 10)-1,
|
||||
parseInt(comps[3], 10),
|
||||
parseInt(comps[4], 10),
|
||||
parseInt(comps[5], 10),
|
||||
parseInt(comps[6], 10 )
|
||||
));
|
||||
// TODO add tz
|
||||
} else {
|
||||
curr[name] = new Date(
|
||||
parseInt(comps[1], 10),
|
||||
parseInt(comps[2], 10)-1,
|
||||
parseInt(comps[3], 10),
|
||||
parseInt(comps[4], 10),
|
||||
parseInt(comps[5], 10),
|
||||
parseInt(comps[6], 10)
|
||||
);
|
||||
}
|
||||
if (curr[name].length === 0){
|
||||
delete curr[name];
|
||||
} else if (curr[name].length === 1){
|
||||
curr[name] = curr[name][0];
|
||||
}
|
||||
|
||||
return addTZ(curr, name, params)
|
||||
return curr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,7 +164,11 @@
|
||||
if (date.exdates === undefined) {
|
||||
date.exdates = [];
|
||||
}
|
||||
date.exdates.push(date.exdate);
|
||||
if (Array.isArray(date.exdate)){
|
||||
date.exdates = date.exdates.concat(date.exdate);
|
||||
} else {
|
||||
date.exdates.push(date.exdate);
|
||||
}
|
||||
return date;
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ Module.register("clock",{
|
||||
analogShowDate: "top", // options: false, 'top', or 'bottom'
|
||||
secondsColor: "#888888",
|
||||
timezone: null,
|
||||
autoTimezone: false
|
||||
},
|
||||
// Define required scripts.
|
||||
getScripts: function() {
|
||||
@ -39,16 +40,31 @@ Module.register("clock",{
|
||||
start: function() {
|
||||
Log.info("Starting module: " + this.name);
|
||||
|
||||
// Schedule update interval.
|
||||
var self = this;
|
||||
setInterval(function() {
|
||||
self.updateDom();
|
||||
}, 1000);
|
||||
if (this.config.autoTimezone) {
|
||||
this.sendSocketNotification("AUTO_TIMEZONE");
|
||||
} else {
|
||||
// Schedule update interval.
|
||||
var self = this;
|
||||
setInterval(function() {
|
||||
self.updateDom();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
// Set locale.
|
||||
moment.locale(config.language);
|
||||
|
||||
},
|
||||
|
||||
socketNotificationReceived: function (notification, payload) {
|
||||
if (notification === "UPDATE_TIMEZONE") {
|
||||
var self = this;
|
||||
self.config.timezone = payload.timezone;
|
||||
setInterval(function() {
|
||||
self.updateDom();
|
||||
}, 1000);
|
||||
}
|
||||
},
|
||||
|
||||
// Override dom generator.
|
||||
getDom: function() {
|
||||
|
||||
@ -137,7 +153,8 @@ Module.register("clock",{
|
||||
clockCircle.style.backgroundSize = "100%";
|
||||
|
||||
// The following line solves issue: https://github.com/MichMich/MagicMirror/issues/611
|
||||
clockCircle.style.border = "1px solid black";
|
||||
// clockCircle.style.border = "1px solid black";
|
||||
clockCircle.style.border = "rgba(0, 0, 0, 0.1)"; //Updated fix for Issue 611 where non-black backgrounds are used
|
||||
|
||||
} else if (this.config.analogFace != "none") {
|
||||
clockCircle.style.border = "2px solid white";
|
||||
|
29
modules/default/clock/node_helper.js
Normal file
29
modules/default/clock/node_helper.js
Normal file
@ -0,0 +1,29 @@
|
||||
var http = require("http");
|
||||
var NodeHelper = require("node_helper");
|
||||
|
||||
module.exports = NodeHelper.create({
|
||||
start: function () {
|
||||
},
|
||||
|
||||
socketNotificationReceived: function (notification, payload) {
|
||||
var self = this;
|
||||
|
||||
if (notification === "AUTO_TIMEZONE") {
|
||||
console.log("Loading timezone...");
|
||||
http.get("http://ip-api.com/json", function (req) {
|
||||
var data = "";
|
||||
req.on("data", function (d) {
|
||||
data += d;
|
||||
});
|
||||
req.on("end", function () {
|
||||
var body = JSON.parse(data);
|
||||
payload.timezone = body.timezone;
|
||||
self.sendSocketNotification("UPDATE_TIMEZONE", payload);
|
||||
});
|
||||
}).on("error", function () {
|
||||
payload.error = "Could not figure out the timezone.";
|
||||
self.sendSocketNotification("UPDATE_TIMEZONE", payload);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
@ -11,6 +11,7 @@ Module.register("currentweather",{
|
||||
|
||||
// Default module config.
|
||||
defaults: {
|
||||
autoLocation: false,
|
||||
location: false,
|
||||
locationID: false,
|
||||
appid: "",
|
||||
@ -109,8 +110,19 @@ Module.register("currentweather",{
|
||||
this.weatherType = null;
|
||||
this.feelsLike = null;
|
||||
this.loaded = false;
|
||||
this.scheduleUpdate(this.config.initialLoadDelay);
|
||||
|
||||
if (this.config.autoLocation) {
|
||||
this.sendSocketNotification("AUTO_LOCATION");
|
||||
} else {
|
||||
this.scheduleUpdate(this.config.initialLoadDelay);
|
||||
}
|
||||
},
|
||||
|
||||
socketNotificationReceived: function (notification, payload) {
|
||||
if (notification === "UPDATE_LOCATION") {
|
||||
this.config.location = payload.location;
|
||||
this.scheduleUpdate(this.config.initialLoadDelay);
|
||||
}
|
||||
},
|
||||
|
||||
// add extra information of current weather
|
||||
@ -198,16 +210,19 @@ Module.register("currentweather",{
|
||||
large.appendChild(weatherIcon);
|
||||
|
||||
var degreeLabel = "";
|
||||
if (this.config.degreeLabel) {
|
||||
switch (this.config.units ) {
|
||||
if (this.config.units === "metric" || this.config.units === "imperial") {
|
||||
degreeLabel += "°";
|
||||
}
|
||||
if(this.config.degreeLabel) {
|
||||
switch(this.config.units) {
|
||||
case "metric":
|
||||
degreeLabel = "C";
|
||||
degreeLabel += "C";
|
||||
break;
|
||||
case "imperial":
|
||||
degreeLabel = "F";
|
||||
degreeLabel += "F";
|
||||
break;
|
||||
case "default":
|
||||
degreeLabel = "K";
|
||||
degreeLabel += "K";
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -218,7 +233,7 @@ Module.register("currentweather",{
|
||||
|
||||
var temperature = document.createElement("span");
|
||||
temperature.className = "bright";
|
||||
temperature.innerHTML = " " + this.temperature.replace(".", this.config.decimalSymbol) + "°" + degreeLabel;
|
||||
temperature.innerHTML = " " + this.temperature.replace(".", this.config.decimalSymbol) + degreeLabel;
|
||||
large.appendChild(temperature);
|
||||
|
||||
if (this.config.showIndoorTemperature && this.indoorTemperature) {
|
||||
@ -228,7 +243,7 @@ Module.register("currentweather",{
|
||||
|
||||
var indoorTemperatureElem = document.createElement("span");
|
||||
indoorTemperatureElem.className = "bright";
|
||||
indoorTemperatureElem.innerHTML = " " + this.indoorTemperature.replace(".", this.config.decimalSymbol) + "°" + degreeLabel;
|
||||
indoorTemperatureElem.innerHTML = " " + this.indoorTemperature.replace(".", this.config.decimalSymbol) + degreeLabel;
|
||||
large.appendChild(indoorTemperatureElem);
|
||||
}
|
||||
|
||||
@ -251,7 +266,7 @@ Module.register("currentweather",{
|
||||
|
||||
var feelsLike = document.createElement("span");
|
||||
feelsLike.className = "dimmed";
|
||||
feelsLike.innerHTML = this.translate("FEELS") + " " + this.feelsLike + "°" + degreeLabel;
|
||||
feelsLike.innerHTML = this.translate("FEELS") + " " + this.feelsLike + degreeLabel;
|
||||
small.appendChild(feelsLike);
|
||||
|
||||
wrapper.appendChild(small);
|
||||
|
29
modules/default/currentweather/node_helper.js
Normal file
29
modules/default/currentweather/node_helper.js
Normal file
@ -0,0 +1,29 @@
|
||||
var http = require("http");
|
||||
var NodeHelper = require("node_helper");
|
||||
|
||||
module.exports = NodeHelper.create({
|
||||
start: function () {
|
||||
},
|
||||
|
||||
socketNotificationReceived: function (notification, payload) {
|
||||
var self = this;
|
||||
|
||||
if (notification === "AUTO_LOCATION") {
|
||||
console.log("Loading timezone...");
|
||||
http.get("http://ip-api.com/json", function (req) {
|
||||
var data = "";
|
||||
req.on("data", function (d) {
|
||||
data += d;
|
||||
});
|
||||
req.on("end", function () {
|
||||
var body = JSON.parse(data);
|
||||
payload.location = body.city + ", " + body.regionName;
|
||||
self.sendSocketNotification("UPDATE_LOCATION", payload);
|
||||
});
|
||||
}).on("error", function () {
|
||||
payload.error = "Could not figure out the timezone.";
|
||||
self.sendSocketNotification("UPDATE_LOCATION", payload);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
@ -65,8 +65,10 @@ module.exports = NodeHelper.create({
|
||||
data.module = sg.module;
|
||||
if (!err) {
|
||||
sg.git.log({"-1": null}, function(err, data2) {
|
||||
data.hash = data2.latest.hash;
|
||||
self.sendSocketNotification("STATUS", data);
|
||||
if (!err && data2.latest && "hash" in data2.latest) {
|
||||
data.hash = data2.latest.hash;
|
||||
self.sendSocketNotification("STATUS", data);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
This module is aimed to be the replacement for the current `currentweather` and `weatherforcast` modules. The module will be configurable to be used as a current weather view, or to show the forecast. This way the module can be used twice to fullfil both purposes.
|
||||
|
||||
The biggest cange is the use of weather providers. This way we are not bound to one API source. And users can choose which API they want to use as their source.
|
||||
The biggest change is the use of weather providers. This way we are not bound to one API source. And users can choose which API they want to use as their source.
|
||||
|
||||
The module is in a very early stage, and needs a lot of work. It's API isn't set in stone, so keep that in mind when you want to contribute.
|
||||
|
||||
@ -70,7 +70,10 @@ The following properties can be configured:
|
||||
| ---------------------------- | -----------
|
||||
| `tableClass` | The class for the forecast table. <br><br> **Default value:** `'small'`
|
||||
| `colored` | If set to `true`, the min and max temperature are color coded. <br><br> **Default value:** `false`
|
||||
| `showRainAmount` | Show the amount of rain in the forecast <br><br> **Possible values:** `true` or `false` <br> **Default value:** `true`
|
||||
| `showPrecipitationAmount` | Show the amount of rain/snow in the forecast <br><br> **Possible values:** `true` or `false` <br> **Default value:** `false`
|
||||
| `fade` | Fade the future events to black. (Gradient) <br><br> **Possible values:** `true` or `false` <br> **Default value:** `true`
|
||||
| `fadePoint` | Where to start fade? <br><br> **Possible values:** `0` (top of the list) - `1` (bottom of list) <br> **Default value:** `0.25`
|
||||
| `maxNumberOfDays` | How many days of forecast to return. Specified by config.js <br><br> **Possible values:** `1` - `16` <br> **Default value:** `5` (5 days) <br> This value is optional. By default the weatherforecast module will return 5 days.
|
||||
|
||||
### Openweathermap options
|
||||
|
||||
@ -78,17 +81,17 @@ The following properties can be configured:
|
||||
| ---------------------------- | -----------
|
||||
| `apiVersion` | The OpenWeatherMap API version to use. <br><br> **Default value:** `2.5`
|
||||
| `apiBase` | The OpenWeatherMap base URL. <br><br> **Default value:** `'http://api.openweathermap.org/data/'`
|
||||
| `weatherEndpoint` | The OpenWeatherMap API endPoint. <br><br> **Possible values:** `/weather` or `/forecast/daily` <br> **Default value:** `'/weather'`
|
||||
| `weatherEndpoint` | The OpenWeatherMap API endPoint. <br><br> **Possible values:** `/weather`, `/forecast` (free users) or `/forecast/daily` (paying users or old apiKey only) <br> **Default value:** `'/weather'`
|
||||
| `locationID` | Location ID from [OpenWeatherMap](https://openweathermap.org/find) **This will override anything you put in location.** <br> Leave blank if you want to use location. <br> **Example:** `1234567` <br> **Default value:** `false` <br><br> **Note:** When the `location` and `locationID` are both not set, the location will be based on the information provided by the calendar module. The first upcoming event with location data will be used.
|
||||
| `location` | The location used for weather information. <br><br> **Example:** `'Amsterdam,Netherlands'` <br> **Default value:** `false` <br><br> **Note:** When the `location` and `locationID` are both not set, the location will be based on the information provided by the calendar module. The first upcoming event with location data will be used.
|
||||
| `apiKey` | The [OpenWeatherMap](https://home.openweathermap.org) API key, which can be obtained by creating an OpenWeatherMap account. <br><br> This value is **REQUIRED**
|
||||
| `apiKey` | The [OpenWeatherMap](https://home.openweathermap.org) API key, which can be obtained by creating an OpenWeatherMap account. <br><br> This value is **REQUIRED**
|
||||
|
||||
### Darksky options
|
||||
|
||||
| Option | Description
|
||||
| ---------------------------- | -----------
|
||||
| `apiBase` | The DarkSky base URL. The darksky api has disabled [cors](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), therefore a proxy is required. <br><br> **Possible value:** `'https://cors-anywhere.herokuapp.com/https://api.darksky.net'` <br> This value is **REQUIRED**
|
||||
| `weatherEndpoint` | The DarkSky API endPoint. <br><br> **Possible values:** `/forecast` <br> This value is **REQUIRED**
|
||||
| `weatherEndpoint` | The DarkSky API endPoint. <br><br> **Possible values:** `/forecast` <br> This value is **REQUIRED**
|
||||
| `apiKey` | The [DarkSky](https://darksky.net/dev/register) API key, which can be obtained by creating an DarkSky account. <br><br> This value is **REQUIRED**
|
||||
| `lat` | The geo coordinate latitude. <br><br> This value is **REQUIRED**
|
||||
| `lon` | The geo coordinate longitude. <br><br> This value is **REQUIRED**
|
||||
|
@ -4,31 +4,30 @@
|
||||
<span class="wi wi-strong-wind dimmed"></span>
|
||||
<span>
|
||||
{% if config.useBeaufort %}
|
||||
{{current.beaufortWindSpeed() | round}}
|
||||
{{ current.beaufortWindSpeed() | round }}
|
||||
{% else %}
|
||||
{{current.windSpeed | round}}
|
||||
{{ current.windSpeed | round }}
|
||||
{% endif %}
|
||||
|
||||
{% if config.showWindDirection %}
|
||||
<sup>
|
||||
{% if config.showWindDirectionAsArrow %}
|
||||
<i class="fa fa-long-arrow-up" style="transform:rotate({{current.windDirection}}deg);"></i>
|
||||
<i class="fa fa-long-arrow-up" style="transform:rotate({{ current.windDirection }}deg);"></i>
|
||||
{% else %}
|
||||
{{current.cardinalWindDirection() | translate}}
|
||||
{{ current.cardinalWindDirection() | translate }}
|
||||
{% endif %}
|
||||
|
||||
</sup>
|
||||
{% endif %}
|
||||
</span>
|
||||
{% if config.showHumidity and current.humidity %}
|
||||
<span>{{ current.humidity }}</span><sup> <i class="wi wi-humidity humidityIcon"></i></sup>
|
||||
<span>{{ current.humidity | decimalSymbol }}</span><sup> <i class="wi wi-humidity humidityIcon"></i></sup>
|
||||
{% endif %}
|
||||
<span class="wi dimmed wi-{{current.nextSunAction()}}"></span>
|
||||
<span class="wi dimmed wi-{{ current.nextSunAction() }}"></span>
|
||||
<span>
|
||||
{% if current.nextSunAction() == "sunset" %}
|
||||
{{current.sunset | formatTime}}
|
||||
{{ current.sunset | formatTime }}
|
||||
{% else %}
|
||||
{{current.sunrise | formatTime}}
|
||||
{{ current.sunrise | formatTime }}
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
@ -36,33 +35,39 @@
|
||||
<div class="large light">
|
||||
<span class="wi weathericon wi-{{current.weatherType}}"></span>
|
||||
<span class="bright">
|
||||
{{current.temperature | roundValue | unit("temperature")}}
|
||||
{{ current.temperature | roundValue | unit("temperature") | decimalSymbol }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="normal light indoor">
|
||||
{% if config.showIndoorTemperature and indoor.temperature %}
|
||||
<span class="fa fa-home"></span>
|
||||
<span class="bright">
|
||||
{{indoor.temperature | roundValue | unit("temperature")}}
|
||||
</span>
|
||||
<div>
|
||||
<span class="fa fa-home"></span>
|
||||
<span class="bright">
|
||||
{{ indoor.temperature | roundValue | unit("temperature") | decimalSymbol }}
|
||||
</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if config.showIndoorHumidity and indoor.humidity %}
|
||||
<span class="fa fa-tint"></span>
|
||||
<span class="bright">
|
||||
{{indoor.humidity | roundValue}}%
|
||||
</span>
|
||||
<div>
|
||||
<span class="fa fa-tint"></span>
|
||||
<span class="bright">
|
||||
{{ indoor.humidity | roundValue | unit("humidity") | decimalSymbol }}
|
||||
</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if config.showFeelsLike and not config.onlyTemp %}
|
||||
<div class="normal medium">
|
||||
<span class="dimmed">
|
||||
{{ "FEELS" | translate }} {{ current.feelsLike() | roundValue | unit("temperature") }}
|
||||
{{ "FEELS" | translate }} {{ current.feelsLike() | roundValue | unit("temperature") | decimalSymbol }}
|
||||
</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div class="dimmed light small">
|
||||
{{"LOADING" | translate}}
|
||||
{{ "LOADING" | translate | safe }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Unclomment the line below to see the contents of the `current` object. -->
|
||||
<!-- Uncomment the line below to see the contents of the `current` object. -->
|
||||
<!-- <div style="word-wrap:break-word" class="xsmall dimmed">{{current | dump}}</div> -->
|
||||
|
@ -1,26 +1,32 @@
|
||||
{% if forecast %}
|
||||
<table class="{{config.tableClass}}">
|
||||
{% set numSteps = forecast | calcNumSteps %}
|
||||
{% set currentStep = 0 %}
|
||||
<table class="{{ config.tableClass }}">
|
||||
{% set forecast = forecast.slice(0, numSteps) %}
|
||||
{% for f in forecast %}
|
||||
<tr {% if config.colored %}class="colored"{% endif %}>
|
||||
<td class="day">{{f.date.format('ddd')}}</td>
|
||||
<td class="bright weather-icon"><span class="wi weathericon wi-{{f.weatherType}}"></span></td>
|
||||
<tr {% if config.colored %}class="colored"{% endif %} {% if config.fade %}style="opacity: {{ currentStep | opacity(numSteps) }};"{% endif %}>
|
||||
<td class="day">{{ f.date.format('ddd') }}</td>
|
||||
<td class="bright weather-icon"><span class="wi weathericon wi-{{ f.weatherType }}"></span></td>
|
||||
<td class="align-right bright max-temp">
|
||||
{{f.maxTemperature | roundValue | unit("temperature")}}
|
||||
{{ f.maxTemperature | roundValue | unit("temperature") }}
|
||||
</td>
|
||||
<td class="align-right min-temp">
|
||||
{{f.minTemperature | roundValue | unit("temperature")}}
|
||||
{{ f.minTemperature | roundValue | unit("temperature") }}
|
||||
</td>
|
||||
{% if config.showRainAmount %}
|
||||
<td class="align-right bright rain">
|
||||
{{f.rain | unit("rain")}}
|
||||
{% if config.showPrecipitationAmount %}
|
||||
<td class="align-right bright precipitation">
|
||||
{{ f.precipitation | unit("precip") }}
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% set currentStep = currentStep + 1 %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
{{"LOADING" | translate}}
|
||||
<div class="dimmed light small">
|
||||
{{ "LOADING" | translate | safe }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Unclomment the line below to see the contents of the `current` object. -->
|
||||
<!-- Uncomment the line below to see the contents of the `current` object. -->
|
||||
<!-- <div style="word-wrap:break-word" class="xsmall dimmed">{{forecast | dump}}</div> -->
|
||||
|
@ -103,6 +103,8 @@ A convinience function to make requests. It returns a promise.
|
||||
| weatherType | `string` | Icon name of the weather type. <br> Possible values: [WeatherIcons](https://www.npmjs.com/package/weathericons) |
|
||||
| humidity | `number` | Percentage of humidity |
|
||||
| rain | `number` | Metric: `millimeters` <br> Imperial: `inches` |
|
||||
| snow | `number` | Metric: `millimeters` <br> Imperial: `inches` |
|
||||
| precipitation | `number` | Metric: `millimeters` <br> Imperial: `inches` |
|
||||
|
||||
#### Current weather
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
* MIT Licensed
|
||||
*
|
||||
* This class is a provider for Dark Sky.
|
||||
* Note that the Dark Sky API does not provide rainfall. Instead it provides snowfall and precipitation probability
|
||||
*/
|
||||
WeatherProvider.register("darksky", {
|
||||
// Set the name of the provider.
|
||||
@ -81,12 +82,20 @@ WeatherProvider.register("darksky", {
|
||||
weather.minTemperature = forecast.temperatureMin;
|
||||
weather.maxTemperature = forecast.temperatureMax;
|
||||
weather.weatherType = this.convertWeatherType(forecast.icon);
|
||||
if (this.config.units === "metric" && !isNaN(forecast.precipAccumulation)) {
|
||||
weather.rain = forecast.precipAccumulation * 10;
|
||||
} else {
|
||||
weather.rain = forecast.precipAccumulation;
|
||||
weather.snow = 0;
|
||||
|
||||
// The API will return centimeters if units is 'si' and will return inches for 'us'
|
||||
// Note that the Dark Sky API does not provide rainfall. Instead it provides snowfall and precipitation probability
|
||||
if (forecast.hasOwnProperty("precipAccumulation")) {
|
||||
if (this.config.units === "imperial" && !isNaN(forecast.precipAccumulation)) {
|
||||
weather.snow = forecast.precipAccumulation;
|
||||
} else if (!isNaN(forecast.precipAccumulation)) {
|
||||
weather.snow = forecast.precipAccumulation * 10;
|
||||
}
|
||||
}
|
||||
|
||||
weather.precipitation = weather.snow;
|
||||
|
||||
days.push(weather);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* By Michael Teeuw http://michaelteeuw.nl
|
||||
* MIT Licensed.
|
||||
*
|
||||
*
|
||||
* This class is the blueprint for a weather provider.
|
||||
*/
|
||||
|
||||
@ -56,8 +56,6 @@ WeatherProvider.register("openweathermap", {
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
|
||||
/** OpenWeatherMap Specific Methods - These are not part of the default provider methods */
|
||||
/*
|
||||
* Gets the complete url for the request
|
||||
@ -66,7 +64,7 @@ WeatherProvider.register("openweathermap", {
|
||||
return this.config.apiBase + this.config.apiVersion + this.config.weatherEndpoint + this.getParams();
|
||||
},
|
||||
|
||||
/*
|
||||
/*
|
||||
* Generate a WeatherObject based on currentWeatherInformation
|
||||
*/
|
||||
generateWeatherObjectFromCurrentWeather(currentWeatherData) {
|
||||
@ -87,6 +85,105 @@ WeatherProvider.register("openweathermap", {
|
||||
* Generate WeatherObjects based on forecast information
|
||||
*/
|
||||
generateWeatherObjectsFromForecast(forecasts) {
|
||||
|
||||
if (this.config.weatherEndpoint == "/forecast") {
|
||||
return this.fetchForecastHourly(forecasts);
|
||||
} else if (this.config.weatherEndpoint == "/forecast/daily") {
|
||||
return this.fetchForecastDaily(forecasts);
|
||||
}
|
||||
// if weatherEndpoint does not match forecast or forecast/daily, what should be returned?
|
||||
const days = [new WeatherObject(this.config.units)];
|
||||
return days;
|
||||
},
|
||||
|
||||
/*
|
||||
* fetch forecast information for 3-hourly forecast (available for free subscription).
|
||||
*/
|
||||
fetchForecastHourly(forecasts) {
|
||||
// initial variable declaration
|
||||
const days = [];
|
||||
// variables for temperature range and rain
|
||||
var minTemp = [];
|
||||
var maxTemp = [];
|
||||
var rain = 0;
|
||||
var snow = 0;
|
||||
// variable for date
|
||||
let date = "";
|
||||
var weather = new WeatherObject(this.config.units);
|
||||
|
||||
for (const forecast of forecasts) {
|
||||
|
||||
if (date !== moment(forecast.dt, "X").format("YYYY-MM-DD")) {
|
||||
// calculate minimum/maximum temperature, specify rain amount
|
||||
weather.minTemperature = Math.min.apply(null, minTemp);
|
||||
weather.maxTemperature = Math.max.apply(null, maxTemp);
|
||||
weather.rain = rain;
|
||||
weather.snow = snow;
|
||||
weather.precipitation = weather.rain + weather.snow;
|
||||
// push weather information to days array
|
||||
days.push(weather);
|
||||
// create new weather-object
|
||||
weather = new WeatherObject(this.config.units);
|
||||
|
||||
minTemp = [];
|
||||
maxTemp = [];
|
||||
rain = 0;
|
||||
snow = 0;
|
||||
|
||||
// set new date
|
||||
date = moment(forecast.dt, "X").format("YYYY-MM-DD");
|
||||
|
||||
// specify date
|
||||
weather.date = moment(forecast.dt, "X");
|
||||
|
||||
// If the first value of today is later than 17:00, we have an icon at least!
|
||||
weather.weatherType = this.convertWeatherType(forecast.weather[0].icon);
|
||||
|
||||
}
|
||||
|
||||
if (moment(forecast.dt, "X").format("H") >= 8 && moment(forecast.dt, "X").format("H") <= 17) {
|
||||
weather.weatherType = this.convertWeatherType(forecast.weather[0].icon);
|
||||
}
|
||||
|
||||
// the same day as before
|
||||
// add values from forecast to corresponding variables
|
||||
minTemp.push(forecast.main.temp_min);
|
||||
maxTemp.push(forecast.main.temp_max);
|
||||
|
||||
if (forecast.hasOwnProperty("rain")) {
|
||||
if (this.config.units === "imperial" && !isNaN(forecast.rain["3h"])) {
|
||||
rain += forecast.rain["3h"] / 25.4;
|
||||
} else if (!isNaN(forecast.rain["3h"])) {
|
||||
rain += forecast.rain["3h"];
|
||||
}
|
||||
}
|
||||
|
||||
if (forecast.hasOwnProperty("snow")) {
|
||||
if (this.config.units === "imperial" && !isNaN(forecast.snow["3h"])) {
|
||||
snow += forecast.snow["3h"] / 25.4;
|
||||
} else if (!isNaN(forecast.snow["3h"])) {
|
||||
snow += forecast.snow["3h"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// last day
|
||||
// calculate minimum/maximum temperature, specify rain amount
|
||||
weather.minTemperature = Math.min.apply(null, minTemp);
|
||||
weather.maxTemperature = Math.max.apply(null, maxTemp);
|
||||
weather.rain = rain;
|
||||
weather.snow = snow;
|
||||
weather.precipitation = weather.rain + weather.snow;
|
||||
// push weather information to days array
|
||||
days.push(weather);
|
||||
return days.slice(1);
|
||||
},
|
||||
|
||||
/*
|
||||
* fetch forecast information for daily forecast (available for paid subscription or old apiKey).
|
||||
*/
|
||||
fetchForecastDaily(forecasts) {
|
||||
// initial variable declaration
|
||||
const days = [];
|
||||
|
||||
for (const forecast of forecasts) {
|
||||
@ -96,16 +193,35 @@ WeatherProvider.register("openweathermap", {
|
||||
weather.minTemperature = forecast.temp.min;
|
||||
weather.maxTemperature = forecast.temp.max;
|
||||
weather.weatherType = this.convertWeatherType(forecast.weather[0].icon);
|
||||
if (this.config.units === "imperial" && !isNaN(forecast.rain)) {
|
||||
weather.rain = forecast.rain / 25.4
|
||||
} else {
|
||||
weather.rain = forecast.rain;
|
||||
weather.rain = 0;
|
||||
weather.snow = 0;
|
||||
|
||||
// forecast.rain not available if amount is zero
|
||||
// The API always returns in millimeters
|
||||
if (forecast.hasOwnProperty("rain")) {
|
||||
if (this.config.units === "imperial" && !isNaN(forecast.rain)) {
|
||||
weather.rain = forecast.rain / 25.4;
|
||||
} else if (!isNaN(forecast.rain)) {
|
||||
weather.rain = forecast.rain;
|
||||
}
|
||||
}
|
||||
|
||||
// forecast.snow not available if amount is zero
|
||||
// The API always returns in millimeters
|
||||
if (forecast.hasOwnProperty("snow")) {
|
||||
if (this.config.units === "imperial" && !isNaN(forecast.snow)) {
|
||||
weather.snow = forecast.snow / 25.4;
|
||||
} else if (!isNaN(forecast.snow)) {
|
||||
weather.snow = forecast.snow;
|
||||
}
|
||||
}
|
||||
|
||||
weather.precipitation = weather.rain + weather.snow;
|
||||
|
||||
days.push(weather);
|
||||
}
|
||||
|
||||
return days;
|
||||
return days;
|
||||
},
|
||||
|
||||
/*
|
||||
|
@ -31,11 +31,15 @@
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.weather .rain {
|
||||
.weather .precipitation {
|
||||
padding-left: 20px;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.weather tr .weathericon {
|
||||
line-height: 25px;
|
||||
}
|
||||
|
||||
.weather tr.colored .min-temp {
|
||||
color: #bcddff;
|
||||
}
|
||||
|
@ -30,8 +30,12 @@ Module.register("weather",{
|
||||
lang: config.language,
|
||||
showHumidity: false,
|
||||
degreeLabel: false,
|
||||
decimalSymbol: ".",
|
||||
showIndoorTemperature: false,
|
||||
showIndoorHumidity: false,
|
||||
maxNumberOfDays: 5,
|
||||
fade: true,
|
||||
fadePoint: 0.25, // Start on 1/4th of the list.
|
||||
|
||||
initialLoadDelay: 0, // 0 seconds delay
|
||||
retryDelay: 2500,
|
||||
@ -45,7 +49,7 @@ Module.register("weather",{
|
||||
tableClass: "small",
|
||||
|
||||
onlyTemp: false,
|
||||
showRainAmount: true,
|
||||
showPrecipitationAmount: false,
|
||||
colored: false,
|
||||
showFeelsLike: true
|
||||
},
|
||||
@ -58,7 +62,7 @@ Module.register("weather",{
|
||||
return ["font-awesome.css", "weather-icons.css", "weather.css"];
|
||||
},
|
||||
|
||||
// Return the scripts that are nessecery for the weather module.
|
||||
// Return the scripts that are necessary for the weather module.
|
||||
getScripts: function () {
|
||||
return [
|
||||
"moment.js",
|
||||
@ -184,7 +188,9 @@ Module.register("weather",{
|
||||
|
||||
this.nunjucksEnvironment().addFilter("unit", function (value, type) {
|
||||
if (type === "temperature") {
|
||||
value += "°";
|
||||
if (this.config.units === "metric" || this.config.units === "imperial") {
|
||||
value += "°";
|
||||
}
|
||||
if (this.config.degreeLabel) {
|
||||
if (this.config.units === "metric") {
|
||||
value += "C";
|
||||
@ -194,12 +200,14 @@ Module.register("weather",{
|
||||
value += "K";
|
||||
}
|
||||
}
|
||||
} else if (type === "rain") {
|
||||
if (isNaN(value)) {
|
||||
} else if (type === "precip") {
|
||||
if (isNaN(value) || value === 0 || value.toFixed(2) === "0.00") {
|
||||
value = "";
|
||||
} else {
|
||||
value = `${value.toFixed(2)} ${this.config.units === "imperial" ? "in" : "mm"}`;
|
||||
}
|
||||
} else if (type === "humidity") {
|
||||
value += "%"
|
||||
}
|
||||
|
||||
return value;
|
||||
@ -208,5 +216,30 @@ Module.register("weather",{
|
||||
this.nunjucksEnvironment().addFilter("roundValue", function(value) {
|
||||
return this.roundValue(value);
|
||||
}.bind(this));
|
||||
|
||||
this.nunjucksEnvironment().addFilter("decimalSymbol", function(value) {
|
||||
return value.toString().replace(/\./g, this.config.decimalSymbol);
|
||||
}.bind(this));
|
||||
|
||||
this.nunjucksEnvironment().addFilter("calcNumSteps", function(forecast) {
|
||||
return Math.min(forecast.length, this.config.maxNumberOfDays);
|
||||
}.bind(this));
|
||||
|
||||
this.nunjucksEnvironment().addFilter("opacity", function(currentStep, numSteps) {
|
||||
if (this.config.fade && this.config.fadePoint < 1) {
|
||||
if (this.config.fadePoint < 0) {
|
||||
this.config.fadePoint = 0;
|
||||
}
|
||||
var startingPoint = numSteps * this.config.fadePoint;
|
||||
var numFadesteps = numSteps - startingPoint;
|
||||
if (currentStep >= startingPoint) {
|
||||
return 1 - (currentStep - startingPoint) / numFadesteps;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
});
|
||||
|
@ -26,6 +26,8 @@ class WeatherObject {
|
||||
this.weatherType = null;
|
||||
this.humidity = null;
|
||||
this.rain = null;
|
||||
this.snow = null;
|
||||
this.precipitation = null;
|
||||
}
|
||||
|
||||
cardinalWindDirection() {
|
||||
|
29
modules/default/weatherforecast/node_helper.js
Normal file
29
modules/default/weatherforecast/node_helper.js
Normal file
@ -0,0 +1,29 @@
|
||||
var http = require("http");
|
||||
var NodeHelper = require("node_helper");
|
||||
|
||||
module.exports = NodeHelper.create({
|
||||
start: function () {
|
||||
},
|
||||
|
||||
socketNotificationReceived: function (notification, payload) {
|
||||
var self = this;
|
||||
|
||||
if (notification === "AUTO_LOCATION") {
|
||||
console.log("Loading timezone...");
|
||||
http.get("http://ip-api.com/json", function (req) {
|
||||
var data = "";
|
||||
req.on("data", function (d) {
|
||||
data += d;
|
||||
});
|
||||
req.on("end", function () {
|
||||
var body = JSON.parse(data);
|
||||
payload.location = body.city + ", " + body.regionName;
|
||||
self.sendSocketNotification("UPDATE_LOCATION", payload);
|
||||
});
|
||||
}).on("error", function () {
|
||||
payload.error = "Could not figure out the timezone.";
|
||||
self.sendSocketNotification("UPDATE_LOCATION", payload);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
@ -11,6 +11,7 @@ Module.register("weatherforecast",{
|
||||
|
||||
// Default module config.
|
||||
defaults: {
|
||||
autoLocation: false,
|
||||
location: false,
|
||||
locationID: false,
|
||||
appid: "",
|
||||
@ -95,10 +96,20 @@ Module.register("weatherforecast",{
|
||||
|
||||
this.forecast = [];
|
||||
this.loaded = false;
|
||||
this.scheduleUpdate(this.config.initialLoadDelay);
|
||||
|
||||
this.updateTimer = null;
|
||||
|
||||
if (this.config.autoLocation) {
|
||||
this.sendSocketNotification("AUTO_LOCATION");
|
||||
} else {
|
||||
this.scheduleUpdate(this.config.initialLoadDelay);
|
||||
}
|
||||
},
|
||||
|
||||
socketNotificationReceived: function (notification, payload) {
|
||||
if (notification === "UPDATE_LOCATION") {
|
||||
this.config.location = payload.location;
|
||||
this.scheduleUpdate(this.config.initialLoadDelay);
|
||||
}
|
||||
},
|
||||
|
||||
// Override dom generator.
|
||||
@ -142,14 +153,17 @@ Module.register("weatherforecast",{
|
||||
icon.className = "wi weathericon " + forecast.icon;
|
||||
iconCell.appendChild(icon);
|
||||
|
||||
var degreeLabel = "°";
|
||||
var degreeLabel = "";
|
||||
if (this.config.units === "metric" || this.config.units === "imperial") {
|
||||
degreeLabel += "°";
|
||||
}
|
||||
if(this.config.scale) {
|
||||
switch(this.config.units) {
|
||||
case "metric":
|
||||
degreeLabel += " C";
|
||||
degreeLabel += "C";
|
||||
break;
|
||||
case "imperial":
|
||||
degreeLabel += " F";
|
||||
degreeLabel += "F";
|
||||
break;
|
||||
case "default":
|
||||
degreeLabel = "K";
|
||||
|
713
package-lock.json
generated
713
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "magicmirror",
|
||||
"version": "2.6.0",
|
||||
"version": "2.7.0-develop",
|
||||
"description": "The open source modular smart mirror platform.",
|
||||
"main": "js/electron.js",
|
||||
"scripts": {
|
||||
@ -58,7 +58,7 @@
|
||||
"ajv": "6.5.5",
|
||||
"body-parser": "^1.18.2",
|
||||
"colors": "^1.1.2",
|
||||
"electron": "^2.0.16",
|
||||
"electron": "^3.0.13",
|
||||
"express": "^4.16.2",
|
||||
"express-ipfilter": "0.3.1",
|
||||
"feedme": "latest",
|
||||
|
@ -1,6 +1,5 @@
|
||||
var app = require("../js/app.js");
|
||||
app.start(function(config) {
|
||||
console.log("");
|
||||
var bindAddress = config.address ? config.address : "localhost";
|
||||
console.log("Ready to go! Please point your browser to: http://" + bindAddress + ":" + config.port);
|
||||
console.log("\nReady to go! Please point your browser to: http://" + bindAddress + ":" + config.port);
|
||||
});
|
||||
|
@ -36,7 +36,7 @@ describe("Electron app environment", function() {
|
||||
it("should open a browserwindow", function() {
|
||||
return app.client
|
||||
.waitUntilWindowLoaded()
|
||||
.browserWindow.focus()
|
||||
// .browserWindow.focus()
|
||||
.getWindowCount()
|
||||
.should.eventually.equal(1)
|
||||
.browserWindow.isMinimized()
|
||||
|
@ -6,6 +6,8 @@
|
||||
"DAYAFTERTOMORROW": "I overmorgen",
|
||||
"RUNNING": "Slutter om",
|
||||
"EMPTY": "Ingen kommende begivenheder.",
|
||||
"FEELS": "Føles som",
|
||||
"WEEK": "Uge {weekNumber}",
|
||||
|
||||
"N": "N",
|
||||
"NNE": "NNØ",
|
||||
|
@ -29,5 +29,7 @@
|
||||
"UPDATE_NOTIFICATION": "E' disponibile un aggiornamento di MagicMirror².",
|
||||
"UPDATE_NOTIFICATION_MODULE": "E' disponibile un aggiornamento del modulo {MODULE_NAME}.",
|
||||
"UPDATE_INFO_SINGLE": "L'installazione è {COMMIT_COUNT} commit indietro rispetto all'attuale branch {BRANCH_NAME}.",
|
||||
"UPDATE_INFO_MULTIPLE": "L'installazione è {COMMIT_COUNT} commits indietro rispetto all'attuale branch {BRANCH_NAME}."
|
||||
"UPDATE_INFO_MULTIPLE": "L'installazione è {COMMIT_COUNT} commits indietro rispetto all'attuale branch {BRANCH_NAME}.",
|
||||
|
||||
"FEELS": "Percepiti"
|
||||
}
|
||||
|
2
vendor/css/font-awesome.css
vendored
Normal file
2
vendor/css/font-awesome.css
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
@import url("../node_modules/@fortawesome/fontawesome-free/css/all.min.css");
|
||||
@import url("../node_modules/@fortawesome/fontawesome-free/css/v4-shims.min.css");
|
1
vendor/package.json
vendored
1
vendor/package.json
vendored
@ -11,7 +11,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-free": "^5.3.1",
|
||||
"font-awesome": "^4.7.0",
|
||||
"moment": "^2.17.1",
|
||||
"moment-timezone": "^0.5.11",
|
||||
"nunjucks": "^3.0.1",
|
||||
|
4
vendor/vendor.js
vendored
4
vendor/vendor.js
vendored
@ -12,9 +12,7 @@ var vendor = {
|
||||
"moment-timezone.js" : "node_modules/moment-timezone/builds/moment-timezone-with-data.js",
|
||||
"weather-icons.css": "node_modules/weathericons/css/weather-icons.css",
|
||||
"weather-icons-wind.css": "node_modules/weathericons/css/weather-icons-wind.css",
|
||||
"font-awesome.css": "node_modules/font-awesome/css/font-awesome.min.css",
|
||||
"font-awesome5.css": "node_modules/@fortawesome/fontawesome-free/css/all.min.css",
|
||||
"font-awesome5.v4shims.css": "node_modules/@fortawesome/fontawesome-free/css/v4-shims.min.css",
|
||||
"font-awesome.css": "css/font-awesome.css",
|
||||
"nunjucks.js": "node_modules/nunjucks/browser/nunjucks.min.js"
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user