mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add icon translations to Starline (#112241)
This commit is contained in:
parent
e53dcea007
commit
b07e9df308
@ -19,7 +19,6 @@ BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
|
|||||||
BinarySensorEntityDescription(
|
BinarySensorEntityDescription(
|
||||||
key="hbrake",
|
key="hbrake",
|
||||||
translation_key="hand_brake",
|
translation_key="hand_brake",
|
||||||
icon="mdi:car-brake-parking",
|
|
||||||
),
|
),
|
||||||
BinarySensorEntityDescription(
|
BinarySensorEntityDescription(
|
||||||
key="hood",
|
key="hood",
|
||||||
@ -45,19 +44,16 @@ BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
|
|||||||
key="hfree",
|
key="hfree",
|
||||||
translation_key="handsfree",
|
translation_key="handsfree",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
icon="mdi:hand-back-right",
|
|
||||||
),
|
),
|
||||||
BinarySensorEntityDescription(
|
BinarySensorEntityDescription(
|
||||||
key="neutral",
|
key="neutral",
|
||||||
translation_key="neutral",
|
translation_key="neutral",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
icon="mdi:car-shift-pattern",
|
|
||||||
),
|
),
|
||||||
BinarySensorEntityDescription(
|
BinarySensorEntityDescription(
|
||||||
key="arm_moving_pb",
|
key="arm_moving_pb",
|
||||||
translation_key="moving_ban",
|
translation_key="moving_ban",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
icon="mdi:car-off",
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ BUTTON_TYPES: tuple[ButtonEntityDescription, ...] = (
|
|||||||
ButtonEntityDescription(
|
ButtonEntityDescription(
|
||||||
key="poke",
|
key="poke",
|
||||||
translation_key="horn",
|
translation_key="horn",
|
||||||
icon="mdi:bullhorn-outline",
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -60,8 +60,3 @@ class StarlineDeviceTracker(StarlineEntity, TrackerEntity, RestoreEntity):
|
|||||||
def source_type(self) -> SourceType:
|
def source_type(self) -> SourceType:
|
||||||
"""Return the source type, eg gps or router, of the device."""
|
"""Return the source type, eg gps or router, of the device."""
|
||||||
return SourceType.GPS
|
return SourceType.GPS
|
||||||
|
|
||||||
@property
|
|
||||||
def icon(self):
|
|
||||||
"""Return the icon to use in the frontend, if any."""
|
|
||||||
return "mdi:map-marker-outline"
|
|
||||||
|
79
homeassistant/components/starline/icons.json
Normal file
79
homeassistant/components/starline/icons.json
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
@ -62,13 +62,6 @@ class StarlineLock(StarlineEntity, LockEntity):
|
|||||||
"""
|
"""
|
||||||
return self._device.alarm_state
|
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
|
@property
|
||||||
def is_locked(self) -> bool | None:
|
def is_locked(self) -> bool | None:
|
||||||
"""Return true if lock is locked."""
|
"""Return true if lock is locked."""
|
||||||
|
@ -33,7 +33,6 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="balance",
|
key="balance",
|
||||||
translation_key="balance",
|
translation_key="balance",
|
||||||
icon="mdi:cash-multiple",
|
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="ctemp",
|
key="ctemp",
|
||||||
@ -55,12 +54,10 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="fuel",
|
key="fuel",
|
||||||
translation_key="fuel",
|
translation_key="fuel",
|
||||||
icon="mdi:fuel",
|
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="errors",
|
key="errors",
|
||||||
translation_key="errors",
|
translation_key="errors",
|
||||||
icon="mdi:alert-octagon",
|
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
@ -68,12 +65,10 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||||||
translation_key="mileage",
|
translation_key="mileage",
|
||||||
native_unit_of_measurement=UnitOfLength.KILOMETERS,
|
native_unit_of_measurement=UnitOfLength.KILOMETERS,
|
||||||
device_class=SensorDeviceClass.DISTANCE,
|
device_class=SensorDeviceClass.DISTANCE,
|
||||||
icon="mdi:counter",
|
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="gps_count",
|
key="gps_count",
|
||||||
translation_key="gps_count",
|
translation_key="gps_count",
|
||||||
icon="mdi:satellite-variant",
|
|
||||||
native_unit_of_measurement="satellites",
|
native_unit_of_measurement="satellites",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""Support for StarLine switch."""
|
"""Support for StarLine switch."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
|
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
|
||||||
@ -14,53 +13,27 @@ from .account import StarlineAccount, StarlineDevice
|
|||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .entity import StarlineEntity
|
from .entity import StarlineEntity
|
||||||
|
|
||||||
|
SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
|
||||||
@dataclass(frozen=True)
|
SwitchEntityDescription(
|
||||||
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(
|
|
||||||
key="ign",
|
key="ign",
|
||||||
translation_key="engine",
|
translation_key="engine",
|
||||||
icon_on="mdi:engine-outline",
|
|
||||||
icon_off="mdi:engine-off-outline",
|
|
||||||
),
|
),
|
||||||
StarlineSwitchEntityDescription(
|
SwitchEntityDescription(
|
||||||
key="webasto",
|
key="webasto",
|
||||||
translation_key="webasto",
|
translation_key="webasto",
|
||||||
icon_on="mdi:radiator",
|
|
||||||
icon_off="mdi:radiator-off",
|
|
||||||
),
|
),
|
||||||
StarlineSwitchEntityDescription(
|
SwitchEntityDescription(
|
||||||
key="out",
|
key="out",
|
||||||
translation_key="additional_channel",
|
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
|
# Deprecated and should be removed in 2024.8
|
||||||
StarlineSwitchEntityDescription(
|
SwitchEntityDescription(
|
||||||
key="poke",
|
key="poke",
|
||||||
translation_key="horn",
|
translation_key="horn",
|
||||||
icon_on="mdi:bullhorn-outline",
|
|
||||||
icon_off="mdi:bullhorn-outline",
|
|
||||||
),
|
),
|
||||||
StarlineSwitchEntityDescription(
|
SwitchEntityDescription(
|
||||||
key="valet",
|
key="valet",
|
||||||
translation_key="service_mode",
|
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):
|
class StarlineSwitch(StarlineEntity, SwitchEntity):
|
||||||
"""Representation of a StarLine switch."""
|
"""Representation of a StarLine switch."""
|
||||||
|
|
||||||
entity_description: StarlineSwitchEntityDescription
|
|
||||||
|
|
||||||
_attr_assumed_state = True
|
_attr_assumed_state = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
account: StarlineAccount,
|
account: StarlineAccount,
|
||||||
device: StarlineDevice,
|
device: StarlineDevice,
|
||||||
description: StarlineSwitchEntityDescription,
|
description: SwitchEntityDescription,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the switch."""
|
"""Initialize the switch."""
|
||||||
super().__init__(account, device, description.key)
|
super().__init__(account, device, description.key)
|
||||||
@ -109,15 +80,6 @@ class StarlineSwitch(StarlineEntity, SwitchEntity):
|
|||||||
return self._account.engine_attrs(self._device)
|
return self._account.engine_attrs(self._device)
|
||||||
return None
|
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
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Return True if entity is on."""
|
"""Return True if entity is on."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user