mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +00:00
Allow setting device_class
"outlet" again through entity settings (#12669)
* Allow setting `device_class` "outlet" again through UI * Fixes * Null check deviceClass and adjust used translation
This commit is contained in:
parent
b71b230bfd
commit
49c018c000
@ -367,9 +367,24 @@ export class EntityRegistrySettings extends SubscribeMixin(LitElement) {
|
||||
@selected=${this._switchAsChanged}
|
||||
@closed=${stopPropagation}
|
||||
>
|
||||
<mwc-list-item value="switch" selected>
|
||||
${domainToName(this.hass.localize, "switch")}</mwc-list-item
|
||||
<mwc-list-item
|
||||
value="switch"
|
||||
.selected=${!this._deviceClass ||
|
||||
this._deviceClass === "switch"}
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.dialogs.entity_registry.editor.device_classes.switch.switch"
|
||||
)}
|
||||
</mwc-list-item>
|
||||
<mwc-list-item
|
||||
value="outlet"
|
||||
.selected=${!this._deviceClass ||
|
||||
this._deviceClass === "outlet"}
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.dialogs.entity_registry.editor.device_classes.switch.outlet"
|
||||
)}
|
||||
</mwc-list-item>
|
||||
<li divider role="separator"></li>
|
||||
${this._switchAsDomainsSorted(
|
||||
SWITCH_AS_DOMAINS,
|
||||
@ -617,7 +632,15 @@ export class EntityRegistrySettings extends SubscribeMixin(LitElement) {
|
||||
if (ev.target.value === "") {
|
||||
return;
|
||||
}
|
||||
this._switchAs = ev.target.value;
|
||||
|
||||
// If value is "outlet" that means the user kept the "switch" domain, but actually changed
|
||||
// the device_class of the switch to "outlet".
|
||||
const switchAs = ev.target.value === "outlet" ? "switch" : ev.target.value;
|
||||
this._switchAs = switchAs;
|
||||
|
||||
if (ev.target.value === "outlet" || ev.target.value === "switch") {
|
||||
this._deviceClass = ev.target.value;
|
||||
}
|
||||
}
|
||||
|
||||
private _areaPicked(ev: CustomEvent) {
|
||||
|
@ -853,6 +853,10 @@
|
||||
"curtain": "Curtain",
|
||||
"damper": "Damper",
|
||||
"shutter": "Shutter"
|
||||
},
|
||||
"switch": {
|
||||
"outlet": "Outlet",
|
||||
"switch": "Switch"
|
||||
}
|
||||
},
|
||||
"unavailable": "This entity is unavailable.",
|
||||
|
Loading…
x
Reference in New Issue
Block a user