From c507e71d0d647518c6b7159a62cca4a046110187 Mon Sep 17 00:00:00 2001 From: Patrik Bodin Date: Tue, 15 Sep 2026 05:25:48 -0700 Subject: [PATCH] scrape: fix unit_of_measurement field hardcoded to temperature units (#181361) Co-authored-by: G Johansson --- homeassistant/components/scrape/config_flow.py | 15 ++++++++++----- homeassistant/components/scrape/strings.json | 7 ------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/scrape/config_flow.py b/homeassistant/components/scrape/config_flow.py index 332be51434aa..9f497971956a 100644 --- a/homeassistant/components/scrape/config_flow.py +++ b/homeassistant/components/scrape/config_flow.py @@ -15,7 +15,7 @@ from homeassistant.components.rest.schema import ( # pylint: disable=home-assis DEFAULT_METHOD, METHODS, ) -from homeassistant.components.sensor import CONF_STATE_CLASS +from homeassistant.components.sensor import CONF_STATE_CLASS, DEVICE_CLASS_UNITS from homeassistant.config_entries import ( SOURCE_USER, ConfigEntry, @@ -45,7 +45,6 @@ from homeassistant.const import ( HTTP_BASIC_AUTHENTICATION, HTTP_DIGEST_AUTHENTICATION, Platform, - UnitOfTemperature, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.selector import ( @@ -161,10 +160,16 @@ SENSOR_SETTINGS = probatio.Schema( probatio.Optional(CONF_STATE_CLASS): StateClassSelector(), probatio.Optional(CONF_UNIT_OF_MEASUREMENT): SelectSelector( SelectSelectorConfig( - options=[cls.value for cls in UnitOfTemperature], - custom_value=True, + options=list( + { + str(unit) + for units in DEVICE_CLASS_UNITS.values() + for unit in units + if unit is not None + } + ), mode=SelectSelectorMode.DROPDOWN, - translation_key="unit_of_measurement", + custom_value=True, sort=True, ) ), diff --git a/homeassistant/components/scrape/strings.json b/homeassistant/components/scrape/strings.json index 7e9f10a962c4..f12a07234605 100644 --- a/homeassistant/components/scrape/strings.json +++ b/homeassistant/components/scrape/strings.json @@ -175,12 +175,5 @@ } } } - }, - "selector": { - "unit_of_measurement": { - "options": { - "none": "No unit of measurement" - } - } } }