mirror of
https://github.com/home-assistant/core.git
synced 2026-09-26 09:23:17 -04:00
scrape: fix unit_of_measurement field hardcoded to temperature units (#181361)
Co-authored-by: G Johansson <goran.johansson@shiftit.se>
This commit is contained in:
co-authored by
G Johansson
parent
162089a874
commit
c507e71d0d
@@ -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,
|
||||
)
|
||||
),
|
||||
|
||||
@@ -175,12 +175,5 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"selector": {
|
||||
"unit_of_measurement": {
|
||||
"options": {
|
||||
"none": "No unit of measurement"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user