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

View File

@@ -0,0 +1,34 @@
import {Controller} from "./controller.js";
export class MediaPlayerController extends Controller {
get _value() {
return (this.stateObj.is_volume_muted === "on")
? 0
: Math.ceil(this.stateObj.attributes.volume_level*100.0);
}
set _value(value) {
value = value/100.0;
this._hass.callService("media_player", "volume_set", {
entity_id: this.stateObj.entity_id,
volume_level: value,
});
}
get isOff() {
return this.stateObj.state === "off";
}
get string() {
if (this.stateObj.attributes.is_volume_muted)
return "-";
return !!this.stateObj.attributes.volume_level
? `${this.value} %`
: this._hass.localize("state.media_player.off");
}
get hasToggle() {
return false;
}
}