Total overhaul!

This commit is contained in:
2019-06-13 22:45:59 +02:00
parent 46be70ee49
commit 1d29e2365f
14 changed files with 611 additions and 436 deletions

40
src/cover-controller.js Normal file
View File

@@ -0,0 +1,40 @@
import {Controller} from "./controller.js";
export class CoverController extends Controller {
get _value() {
return this.stateObj.state === "open"
? this.stateObj.attributes.current_position
: 0;
}
set _value(value) {
this._hass.callService("cover", "set_cover_position", {
entity_id: this.stateObj.entity_id,
position: value,
});
}
get string() {
if (!this.hasSlider)
return "";
if (this.stateObj.state === "closed")
return this._hass.localize("state.cover.closed");
return `${this.value} %`
}
get hasToggle() {
return false;
}
get hasSlider() {
if ("current_position" in this.stateObj.attributes) return true;
if (("supported_features" in this.stateObj.attributes) &&
(this.stateObj.attributes.supported_features & 4)) return true;
return false;
}
get _step() {
return 10;
}
}