dimmer handling part 2

This commit is contained in:
Wolfgang Hottgenroth
2018-01-04 17:34:40 +01:00
parent 717fa42451
commit 7300fa6dbd
2 changed files with 10 additions and 2 deletions

View File

@ -26,11 +26,19 @@ class DimmerAdaptor extends AItem {
this.state = 'OFF'; this.state = 'OFF';
} }
mqtt.send(this.actionStateTopic, this.state, true); mqtt.send(this.actionStateTopic, this.state, true);
mqtt.send(this.actionBrightTopic, this.bright, true);
break; break;
case 'LONG_HOLD': 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; break;
case 'LONG_END': case 'LONG_END':
this.brightDirection = this.brightDirection * -1;
break; break;
} }
break; break;

View File

@ -30,7 +30,7 @@ class HomematicDimmerItem extends AHomematicItem {
dimmerAction() { dimmerAction() {
if ((this.state != this.oldState) || (this.bright != this.oldBright)) { if ((this.state != this.oldState) || (this.bright != this.oldBright)) {
if (this.state == 'ON') { if (this.state == 'ON') {
mqtt.send(this.actionTopic, `${this.bright} / 100.0`); mqtt.send(this.actionTopic, `${this.bright / 100.0}`);
} else { } else {
mqtt.send(this.actionTopic, '0'); mqtt.send(this.actionTopic, '0');
} }