Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions src/panels/config/entities/entity-registry-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,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,
Expand Down Expand Up @@ -570,7 +585,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) {
Expand Down
4 changes: 4 additions & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,10 @@
"curtain": "Curtain",
"damper": "Damper",
"shutter": "Shutter"
},
"switch": {
"outlet": "Outlet",
"switch": "Switch"
}
},
"unavailable": "This entity is unavailable.",
Expand Down