From b83cfd9e548eda24a6baf60f68271f74ea9938e8 Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Fri, 20 Sep 2024 14:49:52 +0200 Subject: [PATCH 1/2] Use icon translations --- custom_components/blitzortung/icons.json | 18 ++++++++++++++++++ custom_components/blitzortung/sensor.py | 8 ++++---- 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 custom_components/blitzortung/icons.json diff --git a/custom_components/blitzortung/icons.json b/custom_components/blitzortung/icons.json new file mode 100644 index 0000000..88abaea --- /dev/null +++ b/custom_components/blitzortung/icons.json @@ -0,0 +1,18 @@ +{ + "entity": { + "sensor": { + "azimuth": { + "default": "mdi:compass-outline" + }, + "counter": { + "default": "mdi:flash" + }, + "distance": { + "default": "mdi:arrow-left-right" + }, + "server_stats": { + "default": "mdi:server" + } + } + } +} \ No newline at end of file diff --git a/custom_components/blitzortung/sensor.py b/custom_components/blitzortung/sensor.py index dc795f4..19a4607 100644 --- a/custom_components/blitzortung/sensor.py +++ b/custom_components/blitzortung/sensor.py @@ -187,29 +187,29 @@ def on_message(self, topic, message): BlitzortungSensorEntityDescription( key=ATTR_LIGHTNING_AZIMUTH, name="Lightning azimuth", + translation_key=ATTR_LIGHTNING_AZIMUTH, has_entity_name=True, native_unit_of_measurement=DEGREE, state_class=SensorStateClass.MEASUREMENT, - icon="mdi:compass-outline", entity_class=AzimuthSensor, ), BlitzortungSensorEntityDescription( key=ATTR_LIGHTNING_COUNTER, name="Lightning counter", + translation_key=ATTR_LIGHTNING_COUNTER, has_entity_name=True, native_unit_of_measurement="↯", state_class=SensorStateClass.MEASUREMENT, - icon="mdi:flash", entity_class=CounterSensor, ), BlitzortungSensorEntityDescription( key=ATTR_LIGHTNING_DISTANCE, name="Lightning distance", + translation_key=ATTR_LIGHTNING_DISTANCE, has_entity_name=True, native_unit_of_measurement=UnitOfLength.KILOMETERS, device_class=SensorDeviceClass.DISTANCE, state_class=SensorStateClass.MEASUREMENT, - icon="mdi:arrow-left-right", entity_class=DistanceSensor, ), ) @@ -250,9 +250,9 @@ def on_message(message): if not sensor: description = BlitzortungSensorEntityDescription( key=topic.replace("/", "_"), + translation_key="server_stats", has_entity_name=False, entity_category=EntityCategory.DIAGNOSTIC, - icon="mdi:server", entity_class=ServerStatSensor, ) sensor = description.entity_class( From 7fe5478c69d5e621f2cca140f4dae2a88c6ec512 Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Fri, 20 Sep 2024 14:51:00 +0200 Subject: [PATCH 2/2] Empty line --- custom_components/blitzortung/icons.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/blitzortung/icons.json b/custom_components/blitzortung/icons.json index 88abaea..f58e5a6 100644 --- a/custom_components/blitzortung/icons.json +++ b/custom_components/blitzortung/icons.json @@ -15,4 +15,4 @@ } } } -} \ No newline at end of file +}