Add device_class to Renault charging remaining time (#98393)

* Add device_class on charging remaining time

Set `device_class to `duration` on the `charging_remaining_time` entity in the Renault integration.

I had some issues showing this property on my dashboard, and setting this fixed it. The recommendation to open an issue against the original integration in these kinds of cases came from [here](https://community.home-assistant.io/t/how-to-format-a-card-to-show-hours-instead-of-seconds/425473/7).

* Update test const to add duration

* fix other cars

* Update test_sensor.ambr

* add duration in ambr
pull/98505/head
Emma Vanbrabant 2023-08-16 08:42:38 +01:00 committed by GitHub
parent c010b97abf
commit 8efb9dad7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 6 deletions

View File

@ -190,6 +190,7 @@ SENSOR_TYPES: tuple[RenaultSensorEntityDescription[Any], ...] = (
key="charging_remaining_time",
coordinator="battery",
data_key="chargingRemainingTime",
device_class=SensorDeviceClass.DURATION,
entity_class=RenaultSensor[KamereonVehicleBatteryStatusData],
icon="mdi:timer",
native_unit_of_measurement=UnitOfTime.MINUTES,

View File

@ -198,6 +198,7 @@ MOCK_VEHICLES = {
ATTR_UNIT_OF_MEASUREMENT: UnitOfPower.KILO_WATT,
},
{
ATTR_DEVICE_CLASS: SensorDeviceClass.DURATION,
ATTR_ENTITY_ID: "sensor.reg_number_charging_remaining_time",
ATTR_ICON: "mdi:timer",
ATTR_STATE: "145",
@ -433,6 +434,7 @@ MOCK_VEHICLES = {
ATTR_UNIT_OF_MEASUREMENT: UnitOfPower.KILO_WATT,
},
{
ATTR_DEVICE_CLASS: SensorDeviceClass.DURATION,
ATTR_ENTITY_ID: "sensor.reg_number_charging_remaining_time",
ATTR_ICON: "mdi:timer",
ATTR_STATE: STATE_UNKNOWN,
@ -668,6 +670,7 @@ MOCK_VEHICLES = {
ATTR_UNIT_OF_MEASUREMENT: UnitOfPower.KILO_WATT,
},
{
ATTR_DEVICE_CLASS: SensorDeviceClass.DURATION,
ATTR_ENTITY_ID: "sensor.reg_number_charging_remaining_time",
ATTR_ICON: "mdi:timer",
ATTR_STATE: "145",

View File

@ -404,7 +404,7 @@
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_device_class': <SensorDeviceClass.DURATION: 'duration'>,
'original_icon': 'mdi:timer',
'original_name': 'Charging remaining time',
'platform': 'renault',
@ -811,6 +811,7 @@
}),
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'REG-NUMBER Charging remaining time',
'icon': 'mdi:timer',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
@ -1100,7 +1101,7 @@
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_device_class': <SensorDeviceClass.DURATION: 'duration'>,
'original_icon': 'mdi:timer',
'original_name': 'Charging remaining time',
'platform': 'renault',
@ -1505,6 +1506,7 @@
}),
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'REG-NUMBER Charging remaining time',
'icon': 'mdi:timer',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
@ -1790,7 +1792,7 @@
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_device_class': <SensorDeviceClass.DURATION: 'duration'>,
'original_icon': 'mdi:timer',
'original_name': 'Charging remaining time',
'platform': 'renault',
@ -2223,6 +2225,7 @@
}),
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'REG-NUMBER Charging remaining time',
'icon': 'mdi:timer',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
@ -2803,7 +2806,7 @@
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_device_class': <SensorDeviceClass.DURATION: 'duration'>,
'original_icon': 'mdi:timer',
'original_name': 'Charging remaining time',
'platform': 'renault',
@ -3210,6 +3213,7 @@
}),
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'REG-NUMBER Charging remaining time',
'icon': 'mdi:timer',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
@ -3499,7 +3503,7 @@
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_device_class': <SensorDeviceClass.DURATION: 'duration'>,
'original_icon': 'mdi:timer',
'original_name': 'Charging remaining time',
'platform': 'renault',
@ -3904,6 +3908,7 @@
}),
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'REG-NUMBER Charging remaining time',
'icon': 'mdi:timer',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
@ -4189,7 +4194,7 @@
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_device_class': <SensorDeviceClass.DURATION: 'duration'>,
'original_icon': 'mdi:timer',
'original_name': 'Charging remaining time',
'platform': 'renault',
@ -4622,6 +4627,7 @@
}),
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'REG-NUMBER Charging remaining time',
'icon': 'mdi:timer',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,