diff --git a/src/main.ts b/src/main.ts index bd43163..054eaf5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,6 +16,16 @@ class SliderEntityRow extends LitElement { @property() hide_state: boolean; @query("ha-slider") _slider?; + getDirection() { + const dir = + this.ctrl.dir ?? + this.hass.translationMetadata.translations[this.hass.language || "en"] + .isRTL + ? "rtl" + : "ltr"; + return dir; + } + setConfig(config: ControllerConfig) { this._config = config; if (!config.entity) throw new Error(`No entity specified.`); @@ -58,6 +68,7 @@ class SliderEntityRow extends LitElement { async connectedCallback() { super.connectedCallback(); await this.resized(); + this._slider?.setAttribute("dir", this.getDirection()); } render() { @@ -74,12 +85,7 @@ class SliderEntityRow extends LitElement { `; - const dir = - c.dir ?? - this.hass.translationMetadata.translations[this.hass.language || "en"] - .isRTL - ? "rtl" - : "ltr"; + const dir = this.getDirection(); const showSlider = c.stateObj.state !== "unavailable" &&