-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
1,148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = tab | ||
indent_size = 4 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# next.js build output | ||
.next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Change Log | ||
|
||
All notable changes to this project is documented in this file. | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## [1.0.0] | ||
|
||
First public release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* Magic Mirror Module: MMM-NestRemoteThermostat (https://github.com/sisimomo/MMM-NestRemoteThermostat) | ||
* By Simon Vallières (https://www.linkedin.com/in/simon-vallieres-358555187/) | ||
* | ||
* Base on Magic Mirror Module: MMM-RemoteTemperature (https://github.com/balassy/MMM-RemoteTemperature) | ||
* By György Balássy (https://www.linkedin.com/in/balassy) | ||
* | ||
* Base on codepen.io example: https://codepen.io/dalhundal/pen/KpabZB | ||
* By Dal Hundal (https://codepen.io/dalhundal) | ||
* | ||
* MIT Licensed. | ||
*/ | ||
|
||
Module.register('MMM-NestRemoteThermostat', { | ||
defaults: { | ||
thermostatId: null, | ||
diameter: undefined, | ||
minValue: undefined, | ||
maxValue: undefined, | ||
numTicks: undefined, | ||
fanIconSize: undefined, | ||
largeBarThickness: undefined, | ||
roundTargetTemperature: undefined, | ||
roundAmbientTemperature: undefined, | ||
language: config.language, | ||
width: '5em', | ||
height: '5em', | ||
}, | ||
|
||
requiresVersion: '2.1.0', | ||
|
||
getScripts() { | ||
return [ | ||
this.file('thermostatDial.js') | ||
]; | ||
}, | ||
|
||
getStyles() { | ||
return [ | ||
this.file('thermostatDial.css') | ||
]; | ||
}, | ||
|
||
getTranslations() { | ||
return { | ||
en: 'translations/en.json', | ||
fr: 'translations/fr.json' | ||
}; | ||
}, | ||
|
||
start() { | ||
this.newValues = {}; | ||
this.sendSocketNotification('MMM-NestRemoteThermostat.INIT', { | ||
thermostatId: this.config.thermostatId | ||
}); | ||
}, | ||
|
||
getDom() { | ||
if (this.thermostat) { | ||
|
||
if (this.newValues.targetTemperature) { | ||
this.thermostat.targetTemperature = this.newValues.targetTemperature; | ||
} | ||
if (this.newValues.ambientTemperature) { | ||
this.thermostat.ambientTemperature = this.newValues.ambientTemperature; | ||
} | ||
if (this.newValues.hvacState) { | ||
this.thermostat.hvacState = this.newValues.hvacState; | ||
} | ||
if (this.newValues.fanSpeed) { | ||
this.thermostat.fanSpeed = this.newValues.fanSpeed; | ||
} | ||
if (this.newValues.loading) { | ||
this.thermostat.loading = this.newValues.loading; | ||
} | ||
this.newValues = {}; | ||
} else { | ||
this.thermostatDiv = document.createElement('div'); | ||
|
||
const translateLocal = (str) => { | ||
return this.translate(str); | ||
} | ||
|
||
this.thermostat = new thermostatDial(this.thermostatDiv, translateLocal, this.config, { | ||
fanSpeeds: [ './modules/MMM-NestRemoteThermostat/images/fanIconSpeed1.gif', './modules/MMM-NestRemoteThermostat/images/fanIconSpeed2.gif', './modules/MMM-NestRemoteThermostat/images/fanIconSpeed3.gif', './modules/MMM-NestRemoteThermostat/images/fanIconSpeed4.gif', './modules/MMM-NestRemoteThermostat/images/fanIconSpeed5.gif' ], | ||
}); | ||
|
||
this.thermostatDiv.style.width = this.config.width; | ||
this.thermostatDiv.style.height = this.config.height; | ||
} | ||
|
||
return this.thermostatDiv; | ||
}, | ||
|
||
socketNotificationReceived(notificationName, payload) { | ||
if (notificationName === 'MMM-NestRemoteThermostat.VALUE_RECEIVED' && payload) { | ||
if (!this.config.thermostatId || (this.config.thermostatId && this.config.thermostatId === payload.thermostatId)) { | ||
this.newValues = { | ||
targetTemperature: payload.targetTemperature, | ||
ambientTemperature: payload.ambientTemperature, | ||
hvacState: payload.hvacState, | ||
fanSpeed: payload.fanSpeed, | ||
loading: payload.loading | ||
}; | ||
Log.info('MMM-NestRemoteThermostat with thermostatId: "' + this.config.thermostatId + '" just receive new values.', this.newValues); | ||
|
||
this.updateDom(); | ||
} | ||
} | ||
} | ||
}); |
Oops, something went wrong.