From 6e99ca0d8a358d20aa9bbc292d38833174659d76 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Tue, 5 Mar 2024 12:58:19 +0100 Subject: [PATCH] Add icon translations to Trafikverket Train (#112322) * Add icon translations to Trafikverket Train * Add icon translations to Trafikverket Train --- .../components/trafikverket_train/icons.json | 39 +++++++++++++++++++ .../components/trafikverket_train/sensor.py | 11 ------ .../snapshots/test_sensor.ambr | 13 ------- 3 files changed, 39 insertions(+), 24 deletions(-) create mode 100644 homeassistant/components/trafikverket_train/icons.json diff --git a/homeassistant/components/trafikverket_train/icons.json b/homeassistant/components/trafikverket_train/icons.json new file mode 100644 index 00000000000..982e3f70b9c --- /dev/null +++ b/homeassistant/components/trafikverket_train/icons.json @@ -0,0 +1,39 @@ +{ + "entity": { + "sensor": { + "departure_time": { + "default": "mdi:clock" + }, + "departure_state": { + "default": "mdi:clock" + }, + "cancelled": { + "default": "mdi:alert" + }, + "delayed_time": { + "default": "mdi:clock" + }, + "planned_time": { + "default": "mdi:clock" + }, + "estimated_time": { + "default": "mdi:clock" + }, + "actual_time": { + "default": "mdi:clock" + }, + "other_info": { + "default": "mdi:information-variant" + }, + "deviation": { + "default": "mdi:alert" + }, + "departure_time_next": { + "default": "mdi:clock" + }, + "departure_time_next_next": { + "default": "mdi:clock" + } + } + } +} diff --git a/homeassistant/components/trafikverket_train/sensor.py b/homeassistant/components/trafikverket_train/sensor.py index 68865a64cb5..3dd513e6650 100644 --- a/homeassistant/components/trafikverket_train/sensor.py +++ b/homeassistant/components/trafikverket_train/sensor.py @@ -43,14 +43,12 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = ( TrafikverketSensorEntityDescription( key="departure_time", translation_key="departure_time", - icon="mdi:clock", device_class=SensorDeviceClass.TIMESTAMP, value_fn=lambda data: data.departure_time, ), TrafikverketSensorEntityDescription( key="departure_state", translation_key="departure_state", - icon="mdi:clock", value_fn=lambda data: data.departure_state, device_class=SensorDeviceClass.ENUM, options=["on_time", "delayed", "canceled"], @@ -58,13 +56,11 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = ( TrafikverketSensorEntityDescription( key="cancelled", translation_key="cancelled", - icon="mdi:alert", value_fn=lambda data: data.cancelled, ), TrafikverketSensorEntityDescription( key="delayed_time", translation_key="delayed_time", - icon="mdi:clock", device_class=SensorDeviceClass.DURATION, native_unit_of_measurement=UnitOfTime.SECONDS, value_fn=lambda data: data.delayed_time, @@ -72,7 +68,6 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = ( TrafikverketSensorEntityDescription( key="planned_time", translation_key="planned_time", - icon="mdi:clock", device_class=SensorDeviceClass.TIMESTAMP, value_fn=lambda data: data.planned_time, entity_registry_enabled_default=False, @@ -80,7 +75,6 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = ( TrafikverketSensorEntityDescription( key="estimated_time", translation_key="estimated_time", - icon="mdi:clock", device_class=SensorDeviceClass.TIMESTAMP, value_fn=lambda data: data.estimated_time, entity_registry_enabled_default=False, @@ -88,7 +82,6 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = ( TrafikverketSensorEntityDescription( key="actual_time", translation_key="actual_time", - icon="mdi:clock", device_class=SensorDeviceClass.TIMESTAMP, value_fn=lambda data: data.actual_time, entity_registry_enabled_default=False, @@ -96,26 +89,22 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = ( TrafikverketSensorEntityDescription( key="other_info", translation_key="other_info", - icon="mdi:information-variant", value_fn=lambda data: data.other_info, ), TrafikverketSensorEntityDescription( key="deviation", translation_key="deviation", - icon="mdi:alert", value_fn=lambda data: data.deviation, ), TrafikverketSensorEntityDescription( key="departure_time_next", translation_key="departure_time_next", - icon="mdi:clock", device_class=SensorDeviceClass.TIMESTAMP, value_fn=lambda data: data.departure_time_next, ), TrafikverketSensorEntityDescription( key="departure_time_next_next", translation_key="departure_time_next_next", - icon="mdi:clock", device_class=SensorDeviceClass.TIMESTAMP, value_fn=lambda data: data.departure_time_next_next, ), diff --git a/tests/components/trafikverket_train/snapshots/test_sensor.ambr b/tests/components/trafikverket_train/snapshots/test_sensor.ambr index 6ea0168926e..96a38b828f4 100644 --- a/tests/components/trafikverket_train/snapshots/test_sensor.ambr +++ b/tests/components/trafikverket_train/snapshots/test_sensor.ambr @@ -5,7 +5,6 @@ 'attribution': 'Data provided by Trafikverket', 'device_class': 'timestamp', 'friendly_name': 'Stockholm C to Uppsala C Departure time', - 'icon': 'mdi:clock', 'product_filter': 'Regionaltåg', }), 'context': , @@ -21,7 +20,6 @@ 'attribution': 'Data provided by Trafikverket', 'device_class': 'enum', 'friendly_name': 'Stockholm C to Uppsala C Departure state', - 'icon': 'mdi:clock', 'options': list([ 'on_time', 'delayed', @@ -42,7 +40,6 @@ 'attribution': 'Data provided by Trafikverket', 'device_class': 'timestamp', 'friendly_name': 'Stockholm C to Uppsala C Departure time next', - 'icon': 'mdi:clock', 'product_filter': 'Regionaltåg', }), 'context': , @@ -58,7 +55,6 @@ 'attribution': 'Data provided by Trafikverket', 'device_class': 'timestamp', 'friendly_name': 'Stockholm C to Uppsala C Departure time next after', - 'icon': 'mdi:clock', 'product_filter': 'Regionaltåg', }), 'context': , @@ -74,7 +70,6 @@ 'attribution': 'Data provided by Trafikverket', 'device_class': 'timestamp', 'friendly_name': 'Stockholm C to Uppsala C Actual time', - 'icon': 'mdi:clock', 'product_filter': 'Regionaltåg', }), 'context': , @@ -89,7 +84,6 @@ 'attributes': ReadOnlyDict({ 'attribution': 'Data provided by Trafikverket', 'friendly_name': 'Stockholm C to Uppsala C Other information', - 'icon': 'mdi:information-variant', 'product_filter': 'Regionaltåg', }), 'context': , @@ -105,7 +99,6 @@ 'attribution': 'Data provided by Trafikverket', 'device_class': 'timestamp', 'friendly_name': 'Stockholm C to Uppsala C Departure time next', - 'icon': 'mdi:clock', 'product_filter': 'Regionaltåg', }), 'context': , @@ -121,7 +114,6 @@ 'attribution': 'Data provided by Trafikverket', 'device_class': 'timestamp', 'friendly_name': 'Stockholm C to Uppsala C Departure time next after', - 'icon': 'mdi:clock', 'product_filter': 'Regionaltåg', }), 'context': , @@ -137,7 +129,6 @@ 'attribution': 'Data provided by Trafikverket', 'device_class': 'timestamp', 'friendly_name': 'Stockholm C to Uppsala C Departure time', - 'icon': 'mdi:clock', 'product_filter': 'Regionaltåg', }), 'context': , @@ -153,7 +144,6 @@ 'attribution': 'Data provided by Trafikverket', 'device_class': 'enum', 'friendly_name': 'Stockholm C to Uppsala C Departure state', - 'icon': 'mdi:clock', 'options': list([ 'on_time', 'delayed', @@ -174,7 +164,6 @@ 'attribution': 'Data provided by Trafikverket', 'device_class': 'timestamp', 'friendly_name': 'Stockholm C to Uppsala C Actual time', - 'icon': 'mdi:clock', 'product_filter': 'Regionaltåg', }), 'context': , @@ -189,7 +178,6 @@ 'attributes': ReadOnlyDict({ 'attribution': 'Data provided by Trafikverket', 'friendly_name': 'Stockholm C to Uppsala C Other information', - 'icon': 'mdi:information-variant', 'product_filter': 'Regionaltåg', }), 'context': , @@ -205,7 +193,6 @@ 'attribution': 'Data provided by Trafikverket', 'device_class': 'timestamp', 'friendly_name': 'Stockholm C to Uppsala C Departure time', - 'icon': 'mdi:clock', }), 'context': , 'entity_id': 'sensor.stockholm_c_to_uppsala_c_departure_time_2',