Add icon translations to Starline (#112241)

pull/112497/head
Joost Lekkerkerker 2024-03-06 12:36:44 +01:00 committed by GitHub
parent e53dcea007
commit b07e9df308
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 86 additions and 67 deletions

View File

@ -19,7 +19,6 @@ BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
BinarySensorEntityDescription(
key="hbrake",
translation_key="hand_brake",
icon="mdi:car-brake-parking",
),
BinarySensorEntityDescription(
key="hood",
@ -45,19 +44,16 @@ BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
key="hfree",
translation_key="handsfree",
entity_category=EntityCategory.DIAGNOSTIC,
icon="mdi:hand-back-right",
),
BinarySensorEntityDescription(
key="neutral",
translation_key="neutral",
entity_category=EntityCategory.DIAGNOSTIC,
icon="mdi:car-shift-pattern",
),
BinarySensorEntityDescription(
key="arm_moving_pb",
translation_key="moving_ban",
entity_category=EntityCategory.DIAGNOSTIC,
icon="mdi:car-off",
),
)

View File

@ -14,7 +14,6 @@ BUTTON_TYPES: tuple[ButtonEntityDescription, ...] = (
ButtonEntityDescription(
key="poke",
translation_key="horn",
icon="mdi:bullhorn-outline",
),
)

View File

@ -60,8 +60,3 @@ class StarlineDeviceTracker(StarlineEntity, TrackerEntity, RestoreEntity):
def source_type(self) -> SourceType:
"""Return the source type, eg gps or router, of the device."""
return SourceType.GPS
@property
def icon(self):
"""Return the icon to use in the frontend, if any."""
return "mdi:map-marker-outline"

View File

@ -0,0 +1,79 @@
{
"entity": {
"binary_sensor": {
"hand_brake": {
"default": "mdi:car-brake-parking"
},
"handsfree": {
"default": "mdi:hand-back-right"
},
"neutral": {
"default": "mdi:car-shift-pattern"
},
"moving_ban": {
"default": "mdi:car-off"
}
},
"button": {
"horn": {
"default": "mdi:bullhorn-outline"
}
},
"device_tracker": {
"location": {
"default": "mdi:map-marker-outline"
}
},
"sensor": {
"balance": {
"default": "mdi:cash-multiple"
},
"fuel": {
"default": "mdi:fuel"
},
"errors": {
"default": "mdi:alert-octagon"
},
"mileage": {
"default": "mdi:counter"
},
"gps_count": {
"default": "mdi:satellite-variant"
}
},
"switch": {
"engine": {
"default": "mdi:engine-off-outline",
"state": {
"on": "mdi:engine-outline"
}
},
"webasto": {
"default": "mdi:radiator-off",
"state": {
"on": "mdi:radiator"
}
},
"additional_channel": {
"default": "mdi:access-point-network-off",
"state": {
"on": "mdi:access-point-network"
}
},
"horn": {
"default": "mdi:bullhorn-outline"
},
"service_mode": {
"default": "mdi:car-wrench",
"state": {
"on": "mdi:wrench-clock"
}
}
}
},
"services": {
"update_state": "mdi:reload",
"set_scan_interval": "mdi:timer",
"set_scan_obd_interval": "mdi:timer"
}
}

View File

@ -62,13 +62,6 @@ class StarlineLock(StarlineEntity, LockEntity):
"""
return self._device.alarm_state
@property
def icon(self) -> str:
"""Icon to use in the frontend, if any."""
return (
"mdi:shield-check-outline" if self.is_locked else "mdi:shield-alert-outline"
)
@property
def is_locked(self) -> bool | None:
"""Return true if lock is locked."""

View File

@ -33,7 +33,6 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="balance",
translation_key="balance",
icon="mdi:cash-multiple",
),
SensorEntityDescription(
key="ctemp",
@ -55,12 +54,10 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="fuel",
translation_key="fuel",
icon="mdi:fuel",
),
SensorEntityDescription(
key="errors",
translation_key="errors",
icon="mdi:alert-octagon",
entity_category=EntityCategory.DIAGNOSTIC,
),
SensorEntityDescription(
@ -68,12 +65,10 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
translation_key="mileage",
native_unit_of_measurement=UnitOfLength.KILOMETERS,
device_class=SensorDeviceClass.DISTANCE,
icon="mdi:counter",
),
SensorEntityDescription(
key="gps_count",
translation_key="gps_count",
icon="mdi:satellite-variant",
native_unit_of_measurement="satellites",
),
)

View File

@ -1,7 +1,6 @@
"""Support for StarLine switch."""
from __future__ import annotations
from dataclasses import dataclass
from typing import Any
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
@ -14,53 +13,27 @@ from .account import StarlineAccount, StarlineDevice
from .const import DOMAIN
from .entity import StarlineEntity
@dataclass(frozen=True)
class StarlineRequiredKeysMixin:
"""Mixin for required keys."""
icon_on: str
icon_off: str
@dataclass(frozen=True)
class StarlineSwitchEntityDescription(
SwitchEntityDescription, StarlineRequiredKeysMixin
):
"""Describes Starline switch entity."""
SWITCH_TYPES: tuple[StarlineSwitchEntityDescription, ...] = (
StarlineSwitchEntityDescription(
SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
SwitchEntityDescription(
key="ign",
translation_key="engine",
icon_on="mdi:engine-outline",
icon_off="mdi:engine-off-outline",
),
StarlineSwitchEntityDescription(
SwitchEntityDescription(
key="webasto",
translation_key="webasto",
icon_on="mdi:radiator",
icon_off="mdi:radiator-off",
),
StarlineSwitchEntityDescription(
SwitchEntityDescription(
key="out",
translation_key="additional_channel",
icon_on="mdi:access-point-network",
icon_off="mdi:access-point-network-off",
),
# Deprecated and should be removed in 2024.8
StarlineSwitchEntityDescription(
SwitchEntityDescription(
key="poke",
translation_key="horn",
icon_on="mdi:bullhorn-outline",
icon_off="mdi:bullhorn-outline",
),
StarlineSwitchEntityDescription(
SwitchEntityDescription(
key="valet",
translation_key="service_mode",
icon_on="mdi:wrench-clock",
icon_off="mdi:car-wrench",
),
)
@ -83,15 +56,13 @@ async def async_setup_entry(
class StarlineSwitch(StarlineEntity, SwitchEntity):
"""Representation of a StarLine switch."""
entity_description: StarlineSwitchEntityDescription
_attr_assumed_state = True
def __init__(
self,
account: StarlineAccount,
device: StarlineDevice,
description: StarlineSwitchEntityDescription,
description: SwitchEntityDescription,
) -> None:
"""Initialize the switch."""
super().__init__(account, device, description.key)
@ -109,15 +80,6 @@ class StarlineSwitch(StarlineEntity, SwitchEntity):
return self._account.engine_attrs(self._device)
return None
@property
def icon(self):
"""Icon to use in the frontend, if any."""
return (
self.entity_description.icon_on
if self.is_on
else self.entity_description.icon_off
)
@property
def is_on(self):
"""Return True if entity is on."""