Skip to content

Commit

Permalink
Merge pull request #126 from bieniu/sensor-icon-translation
Browse files Browse the repository at this point in the history
Sensor icon translation
  • Loading branch information
mrk-its authored Sep 21, 2024
2 parents fa48281 + 7fe5478 commit b210501
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
18 changes: 18 additions & 0 deletions custom_components/blitzortung/icons.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
8 changes: 4 additions & 4 deletions custom_components/blitzortung/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
)
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit b210501

Please sign in to comment.