Skip to content

Commit

Permalink
Merge pull request #51 from rohankapoorcom/fix-localization-entity-st…
Browse files Browse the repository at this point in the history
…ates

Fix localization of entity states
  • Loading branch information
rohankapoorcom authored Aug 12, 2023
2 parents b08f21f + 48be431 commit 3ba12e5
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/controllers/cover-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export class CoverController extends Controller {
}

get label(): string {
const defaultLabel = this._hass.localize(`component.cover.state._.${this.state}`);
const closedLabel = this._hass.localize('component.cover.state._.closed');
const openLabel = this._hass.localize('component.cover.state._.open');
const defaultLabel = this._hass.localize(`component.cover.entity_component._.state.${this.state}`);
const closedLabel = this._hass.localize('component.cover.entity_component._.state.closed');
const openLabel = this._hass.localize('component.cover.entity_component._.state.open');
if (!this.hasSlider) {
return defaultLabel;
}
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/fan-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export class FanController extends Controller {
if (this.hasSlider) {
return `${this.percentage}%`
} else {
return this._hass.localize('component.fan.state._.on');
return this._hass.localize('component.fan.entity_component._.state.on');
}
}
return this._hass.localize('component.fan.state._.off');
return this._hass.localize('component.fan.entity_component._.state.off');
}

get hasSlider(): boolean {
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/input-boolean-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export class InputBooleanController extends Controller {

get label(): string {
if (this.percentage > 0) {
return this._hass.localize('component.input_boolean.state._.on');
return this._hass.localize('component.input_boolean.entity_component._.state.on');
}
return this._hass.localize('component.input_boolean.state._.off');
return this._hass.localize('component.input_boolean.entity_component._.state.off');
}

}
6 changes: 3 additions & 3 deletions src/controllers/light-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ export class LightController extends Controller {

get label(): string {
if (this.isOff) {
return this._hass.localize('component.light.state._.off');
return this._hass.localize('component.light.entity_component._.state.off');
}
if (this.colorMode === LightColorModes.ON_OFF) {
return this._hass.localize('component.light.state._.on');
return this._hass.localize('component.light.entity_component._.state.on');
}
switch(this.attribute) {
case LightAttributes.ON_OFF:
return this._hass.localize('component.light.state._.on');
return this._hass.localize('component.light.entity_component._.state.on');
case LightAttributes.COLOR_TEMP:
case LightAttributes.BRIGHTNESS:
return `${this.targetValue}`;
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/lock-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export class LockController extends Controller {

get label(): string {
if (this.percentage > 0) {
return this._hass.localize('component.lock.state._.unlocked');
return this._hass.localize('component.lock.entity_component._.state.unlocked');
}
return this._hass.localize('component.lock.state._.locked');
return this._hass.localize('component.lock.entity_component._.state.locked');
}

}
4 changes: 2 additions & 2 deletions src/controllers/switch-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export class SwitchController extends Controller {

get label(): string {
if (this.percentage > 0) {
return this._hass.localize('component.switch.state._.on');
return this._hass.localize('component.switch.entity_component._.state.on');
}
return this._hass.localize('component.switch.state._.off');
return this._hass.localize('component.switch.entity_component._.state.off');
}

}

0 comments on commit 3ba12e5

Please sign in to comment.