From 7300fa6dbd96fd2ba3095dc48e2ef8240583f3e6 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Thu, 4 Jan 2018 17:34:40 +0100 Subject: [PATCH] dimmer handling part 2 --- src/DimmerAdaptor.js | 10 +++++++++- src/homematicDimmerItem.js | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/DimmerAdaptor.js b/src/DimmerAdaptor.js index 741181e..cff83e5 100644 --- a/src/DimmerAdaptor.js +++ b/src/DimmerAdaptor.js @@ -26,11 +26,19 @@ class DimmerAdaptor extends AItem { this.state = 'OFF'; } mqtt.send(this.actionStateTopic, this.state, true); - mqtt.send(this.actionBrightTopic, this.bright, true); break; case 'LONG_HOLD': + this.bright += (5 * this.brightDirection); + if (this.bright > 100) { + this.bright = 100; + } + if (this.bright < 0) { + this.bright = 0; + } + mqtt.send(this.actionBrightTopic, this.bright, true); break; case 'LONG_END': + this.brightDirection = this.brightDirection * -1; break; } break; diff --git a/src/homematicDimmerItem.js b/src/homematicDimmerItem.js index 1dc404a..58903f4 100644 --- a/src/homematicDimmerItem.js +++ b/src/homematicDimmerItem.js @@ -30,7 +30,7 @@ class HomematicDimmerItem extends AHomematicItem { dimmerAction() { if ((this.state != this.oldState) || (this.bright != this.oldBright)) { if (this.state == 'ON') { - mqtt.send(this.actionTopic, `${this.bright} / 100.0`); + mqtt.send(this.actionTopic, `${this.bright / 100.0}`); } else { mqtt.send(this.actionTopic, '0'); }