diff --git a/src/data/entity_registry.ts b/src/data/entity_registry.ts
index eaefcee6e363..e77d75c2b55e 100644
--- a/src/data/entity_registry.ts
+++ b/src/data/entity_registry.ts
@@ -41,6 +41,10 @@ export interface EntityRegistryEntryUpdateParams {
disabled_by?: string | null;
hidden_by: string | null;
new_entity_id?: string;
+ options_domain?: string;
+ options?: {
+ unit_of_measurement?: string | null;
+ };
}
export const findBatteryEntity = (
diff --git a/src/panels/config/entities/entity-registry-settings.ts b/src/panels/config/entities/entity-registry-settings.ts
index da5b40359f1c..a5c215bbd6ab 100644
--- a/src/panels/config/entities/entity-registry-settings.ts
+++ b/src/panels/config/entities/entity-registry-settings.ts
@@ -83,6 +83,11 @@ const OVERRIDE_DEVICE_CLASSES = {
],
};
+const OVERRIDE_SENSOR_UNITS = {
+ temperature: ["°C", "°F", "K"],
+ pressure: ["hPa", "Pa", "kPa", "bar", "cbar", "mbar", "mmHg", "inHg", "psi"],
+};
+
@customElement("entity-registry-settings")
export class EntityRegistrySettings extends SubscribeMixin(LitElement) {
@property({ attribute: false }) public hass!: HomeAssistant;
@@ -107,6 +112,8 @@ export class EntityRegistrySettings extends SubscribeMixin(LitElement) {
@state() private _helperConfigEntry?: ConfigEntry;
+ @state() private _unit_of_measurement?: string | null;
+
@state() private _error?: string;
@state() private _submitting?: boolean;
@@ -167,6 +174,13 @@ export class EntityRegistrySettings extends SubscribeMixin(LitElement) {
: undefined;
const domain = computeDomain(this.entry.entity_id);
+
+ if (domain === "sensor") {
+ const stateObj: HassEntity | undefined =
+ this.hass.states[this.entry.entity_id];
+ this._unit_of_measurement = stateObj?.attributes?.unit_of_measurement;
+ }
+
const deviceClasses: string[][] = OVERRIDE_DEVICE_CLASSES[domain];
if (!deviceClasses) {
@@ -269,6 +283,30 @@ export class EntityRegistrySettings extends SubscribeMixin(LitElement) {
`
: ""}
+ ${this._deviceClass &&
+ stateObj.attributes.unit_of_measurement &&
+ OVERRIDE_SENSOR_UNITS[this._deviceClass]?.includes(
+ stateObj.attributes.unit_of_measurement
+ )
+ ? html`
+
+ ${OVERRIDE_SENSOR_UNITS[this._deviceClass].map(
+ (unit: string) => html`
+ ${unit}
+ `
+ )}
+
+ `
+ : ""}