From 48426cbc3b207a820f3e2ffd78759a1b3f520fc6 Mon Sep 17 00:00:00 2001 From: Parnic Date: Tue, 7 Apr 2020 13:03:22 -0500 Subject: [PATCH] Added ability to specify mode used to enable the heater --- CHANGELOG.md | 4 ++++ MMM-ScreenLogic.js | 6 ++++-- README.md | 5 +++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef5ab06..d433dea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/MMM-ScreenLogic.js b/MMM-ScreenLogic.js index 33645c1..1dc0830 100644 --- a/MMM-ScreenLogic.js +++ b/MMM-ScreenLogic.js @@ -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) { @@ -172,7 +173,7 @@ Module.register("MMM-ScreenLogic",{ contents.push({ data: '', class: this.config.contentClass }); @@ -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'); } diff --git a/README.md b/README.md index 81ff0b2..ed6eda2 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ A MagicMirror² 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`.

Each entry in this list is an object with a `type` property and a `name` to display.

Valid `type`s:
`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.
`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)
`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`.

Each entry in this list is an object with a `type` string property and a `name` string to display.

Valid `type`s:
`"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.
`"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").
`"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.| | @@ -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'}, ] } },