Add state_class to starline sensors to generate long-term statistics (#123540)

* starline: Add state_class to sensors to generate long-term statistics

* starline: Add 'errors' unit to 'errors' sensor
This commit is contained in:
Pavel Skuratovich 2024-08-11 13:54:31 +03:00 committed by GitHub
parent 7aed35b3f0
commit 9be8616cc0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,6 +6,7 @@ from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
@ -30,47 +31,57 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
translation_key="battery",
device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="balance",
translation_key="balance",
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="ctemp",
translation_key="interior_temperature",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="etemp",
translation_key="engine_temperature",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="gsm_lvl",
translation_key="gsm_signal",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="fuel",
translation_key="fuel",
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="errors",
translation_key="errors",
native_unit_of_measurement="errors",
entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="mileage",
translation_key="mileage",
native_unit_of_measurement=UnitOfLength.KILOMETERS,
device_class=SensorDeviceClass.DISTANCE,
state_class=SensorStateClass.TOTAL_INCREASING,
),
SensorEntityDescription(
key="gps_count",
translation_key="gps_count",
native_unit_of_measurement="satellites",
state_class=SensorStateClass.MEASUREMENT,
),
)