Skip to content

Commit

Permalink
Added ability to specify mode used to enable the heater
Browse files Browse the repository at this point in the history
  • Loading branch information
parnic committed Apr 7, 2020
1 parent 14b7fdf commit 48426cb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.1] - 2020-03-07
### Added
- Ability to specify which heat mode to use when enabling heating for a specific body. Previously mode 1 was always sent which means "solar" while most people probably want mode 3 which is "heat pump".

## [1.1.0] - 2020-03-01
### Added
- Ability to show buttons for controlling pool equipment (with a touch screen, for example). NOTE: running `npm install` again is necessary after upgrading to this version if the heat controls are used.
Expand Down
6 changes: 4 additions & 2 deletions MMM-ScreenLogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ Module.register("MMM-ScreenLogic",{
}

var on = poolData.status.heatStatus[controlObj.body] !== 0;
var mode = typeof controlObj.heatMode === 'number' ? controlObj.heatMode : 3;

var cls = '';
if (this.config.colored) {
Expand All @@ -172,7 +173,7 @@ Module.register("MMM-ScreenLogic",{

contents.push({
data: '<button id="sl-heat-' + controlObj.body + '" class="control ' + cls + '" onclick="setHeatmode(this)" data-body="' +
controlObj.body + '" data-state="' + (on ? '1' : '0') + '"><div class="content">' +
controlObj.body + '" data-state="' + (on ? '1' : '0') + '" data-mode="' + mode.toString() + '"><div class="content">' +
controlObj.name + '</div></button>',
class: this.config.contentClass
});
Expand Down Expand Up @@ -274,7 +275,8 @@ function setCircuit(e) {
function setHeatmode(e) {
var bodyId = parseInt(e.dataset.body);
var on = e.dataset.state !== '0';
moduleObj.sendSocketNotification('SCREENLOGIC_HEATSTATE', {body: bodyId, state: on ? 0 : 1});
var mode = e.dataset.mode;
moduleObj.sendSocketNotification('SCREENLOGIC_HEATSTATE', {body: bodyId, state: on ? 0 : parseInt(mode)});
e.classList.remove('control-on', 'control-off');
}

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ A <a href="https://github.com/MichMich/MagicMirror">MagicMirror²</a> module use
|`colored`|Boolean|Whether you'd like colored output or not.|`true`|
|`columns`|Integer|How many columns to use to display the data before starting a new row.|`3`|
|`contentClass`|String|The CSS class used to display content values (beneath the header).|`"light"`|
|`controls`|Array|List of controls to show buttons for. Must also set `showControls` to `true`.<br><br>Each entry in this list is an object with a `type` property and a `name` to display.<br><br>Valid `type`s:<br>`circuit` - toggle a circuit on or off. Must also have an `id` property defining the circuit ID to set (see [node-screenlogic](https://github.com/parnic/node-screenlogic) documentation for circuit IDs). `name` is optional; if not specified, the name of the equipment in the ScreenLogic system will be used.<br>`heatmode` - enable or disable the heater for the pool or spa. Must also have a `body` property that defines which body to toggle the heater for (`0` is the pool, `1` is the spa)<br>`heatpoint` - set the heat temperature for the pool or spa. Must also have a `body` property that defines which body to set the heat point for (`0` is the pool, `1` is the spa)|`[]`|
|`controls`|Array|List of controls to show buttons for. Must also set `showControls` to `true`.<br><br>Each entry in this list is an object with a `type` string property and a `name` string to display.<br><br>Valid `type`s:<br>`"circuit"` - toggle a circuit on or off. Must also have an `id` number property defining the circuit ID to set (see [node-screenlogic](https://github.com/parnic/node-screenlogic) documentation for circuit IDs). `name` is an optional string; if not specified, the name of the equipment in the ScreenLogic system will be used.<br>`"heatmode"` - enable or disable the heater for the pool or spa. Must also have a `body` number property that defines which body to toggle the heater for (`0` is the pool, `1` is the spa). Can optionally have a `heatMode` number property that defines which heat mode to set; if not present, defaults to 3 ("heat pump").<br>`"heatpoint"` - set the heat temperature for the pool or spa. Must also have a `body` number property that defines which body to set the heat point for (`0` is the pool, `1` is the spa)|`[]`|
|`hotTemp`|Integer|Show the temperature colored red if it's at or above this level for pool/spa (requires option `colored`). This is in whatever scale your system is set to (Fahrenheit/Celsius).|`90`|
|`serverAddress`|String|The IPv4 address of a ScreenLogic unit to connect to. If not set, the system will search for a unit to connect to. If set, `serverPort` must also be set.| |
|`serverPort`|Integer|The port of a ScreenLogic unit to connect to (usually 80). If not set, the system will search for a unit to connect to. If set, `serverAddress` must also be set.| |
Expand Down Expand Up @@ -43,7 +43,8 @@ Here is an example of an entry in config.js
{type: 'circuit', id: 500},
{type: 'circuit', id: 505, name: 'Pool'},
{type: 'heatmode', body: 0, name: 'Pool heater'},
{type: 'heatpoint', body: 0, name: 'Pool'}
{type: 'heatpoint', body: 0, name: 'Pool'},
{type: 'heatmode', body: 1, heatMode: 2, name: 'Spa heater'},
]
}
},
Expand Down

0 comments on commit 48426cb

Please sign in to comment.