mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Add state_class to metoffice sensors (#145496)
* Add state_class to metoffice sensors * Fix --------- Co-authored-by: Joostlek <joostlek@outlook.com>
This commit is contained in:
parent
c7745e0d02
commit
39906cf65b
@ -12,9 +12,11 @@ from homeassistant.components.sensor import (
|
|||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
|
DEGREE,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
UV_INDEX,
|
UV_INDEX,
|
||||||
UnitOfLength,
|
UnitOfLength,
|
||||||
@ -71,8 +73,8 @@ SENSOR_TYPES: tuple[MetOfficeSensorEntityDescription, ...] = (
|
|||||||
native_attr_name="screenTemperature",
|
native_attr_name="screenTemperature",
|
||||||
name="Temperature",
|
name="Temperature",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
icon=None,
|
|
||||||
entity_registry_enabled_default=True,
|
entity_registry_enabled_default=True,
|
||||||
),
|
),
|
||||||
MetOfficeSensorEntityDescription(
|
MetOfficeSensorEntityDescription(
|
||||||
@ -80,6 +82,7 @@ SENSOR_TYPES: tuple[MetOfficeSensorEntityDescription, ...] = (
|
|||||||
native_attr_name="feelsLikeTemperature",
|
native_attr_name="feelsLikeTemperature",
|
||||||
name="Feels like temperature",
|
name="Feels like temperature",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
icon=None,
|
icon=None,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
@ -93,12 +96,16 @@ SENSOR_TYPES: tuple[MetOfficeSensorEntityDescription, ...] = (
|
|||||||
# This can be removed if we add a mixed metric/imperial unit system for UK users
|
# This can be removed if we add a mixed metric/imperial unit system for UK users
|
||||||
suggested_unit_of_measurement=UnitOfSpeed.MILES_PER_HOUR,
|
suggested_unit_of_measurement=UnitOfSpeed.MILES_PER_HOUR,
|
||||||
device_class=SensorDeviceClass.WIND_SPEED,
|
device_class=SensorDeviceClass.WIND_SPEED,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
entity_registry_enabled_default=True,
|
entity_registry_enabled_default=True,
|
||||||
),
|
),
|
||||||
MetOfficeSensorEntityDescription(
|
MetOfficeSensorEntityDescription(
|
||||||
key="wind_direction",
|
key="wind_direction",
|
||||||
native_attr_name="windDirectionFrom10m",
|
native_attr_name="windDirectionFrom10m",
|
||||||
name="Wind direction",
|
name="Wind direction",
|
||||||
|
native_unit_of_measurement=DEGREE,
|
||||||
|
device_class=SensorDeviceClass.WIND_DIRECTION,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT_ANGLE,
|
||||||
icon="mdi:compass-outline",
|
icon="mdi:compass-outline",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
@ -111,12 +118,15 @@ SENSOR_TYPES: tuple[MetOfficeSensorEntityDescription, ...] = (
|
|||||||
# This can be removed if we add a mixed metric/imperial unit system for UK users
|
# This can be removed if we add a mixed metric/imperial unit system for UK users
|
||||||
suggested_unit_of_measurement=UnitOfSpeed.MILES_PER_HOUR,
|
suggested_unit_of_measurement=UnitOfSpeed.MILES_PER_HOUR,
|
||||||
device_class=SensorDeviceClass.WIND_SPEED,
|
device_class=SensorDeviceClass.WIND_SPEED,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
MetOfficeSensorEntityDescription(
|
MetOfficeSensorEntityDescription(
|
||||||
key="visibility",
|
key="visibility",
|
||||||
native_attr_name="visibility",
|
native_attr_name="visibility",
|
||||||
name="Visibility distance",
|
name="Visibility distance",
|
||||||
|
device_class=SensorDeviceClass.DISTANCE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=UnitOfLength.METERS,
|
native_unit_of_measurement=UnitOfLength.METERS,
|
||||||
icon="mdi:eye",
|
icon="mdi:eye",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
@ -132,6 +142,7 @@ SENSOR_TYPES: tuple[MetOfficeSensorEntityDescription, ...] = (
|
|||||||
MetOfficeSensorEntityDescription(
|
MetOfficeSensorEntityDescription(
|
||||||
key="precipitation",
|
key="precipitation",
|
||||||
native_attr_name="probOfPrecipitation",
|
native_attr_name="probOfPrecipitation",
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
name="Probability of precipitation",
|
name="Probability of precipitation",
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
icon="mdi:weather-rainy",
|
icon="mdi:weather-rainy",
|
||||||
@ -142,6 +153,7 @@ SENSOR_TYPES: tuple[MetOfficeSensorEntityDescription, ...] = (
|
|||||||
native_attr_name="screenRelativeHumidity",
|
native_attr_name="screenRelativeHumidity",
|
||||||
name="Humidity",
|
name="Humidity",
|
||||||
device_class=SensorDeviceClass.HUMIDITY,
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
icon=None,
|
icon=None,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user