Skip to content

Commit

Permalink
First public release.
Browse files Browse the repository at this point in the history
  • Loading branch information
sisimomo committed Aug 15, 2021
1 parent 047fe45 commit 0421c16
Show file tree
Hide file tree
Showing 33 changed files with 1,148 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
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
58 changes: 58 additions & 0 deletions .gitignore
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
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.
111 changes: 111 additions & 0 deletions MMM-NestRemoteThermostat.js
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();
}
}
}
});
Loading

0 comments on commit 0421c16

Please sign in to comment.