diff --git a/src/MQTTConnector.js b/src/MQTTConnector.js index 2c61aec..2063a45 100644 --- a/src/MQTTConnector.js +++ b/src/MQTTConnector.js @@ -50,6 +50,7 @@ class MQTTConnector { let coverConfig = { name: device.id, + state_topic: `${deviceTopic}/state`, command_topic: `${deviceTopic}/set`, position_topic: `${deviceTopic}/state`, set_position_topic: `${deviceTopic}/setposition`, @@ -61,7 +62,13 @@ class MQTTConnector { payload_open: 'OPEN', payload_close: 'CLOSE', payload_stop: 'STOP', + state_open: "open", + state_opening: "opening", + state_closed: "closed", + state_closing: "closing", + state_stopped: "stopped", position_template: '{{value_json[\'position\']}}', + value_template: '{{value_json[\'state\']}}', unique_id: `am43_${device.id}_cover`, device: deviceInfo }; diff --git a/src/am43.js b/src/am43.js index 34b55a0..a46e1a0 100644 --- a/src/am43.js +++ b/src/am43.js @@ -279,28 +279,28 @@ class am43 extends EventEmitter { reevaluateState() { if (this.positionpercentage === 100) { - this.state = 'CLOSED'; + this.state = 'closed'; } else { - this.state = 'OPEN'; + this.state = 'open'; } } am43Open() { this.writeKey(AM43HANDLE, HEX_KEY_OPEN_BLINDS); - this.lastaction = 'OPEN'; - this.state = 'OPEN'; + this.lastaction = 'opening'; + this.state = 'open'; } am43Close() { this.writeKey(AM43HANDLE, HEX_KEY_CLOSE_BLINDS); - this.lastaction = 'CLOSE'; - this.state = 'CLOSED'; + this.lastaction = 'closing'; + this.state = 'closed'; } am43Stop() { this.writeKey(AM43HANDLE, HEX_KEY_STOP_BLINDS); - this.lastaction = 'STOP'; - this.state = 'OPEN'; + this.lastaction = 'stopped'; + this.state = 'open'; } am43GotoPosition(position) @@ -320,11 +320,11 @@ class am43 extends EventEmitter { this.lastaction = 'SET_POSITION'; if(position === 100) { - this.state = 'CLOSED'; + this.state = 'closed'; } else { - this.STATE = 'OPEN'; + this.state = 'open'; } }