mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Add icon translations to Shelly (#110183)
Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
This commit is contained in:
parent
7dc9ad63bd
commit
326da81656
@ -58,7 +58,7 @@ BUTTONS: Final[list[ShellyButtonDescription[Any]]] = [
|
|||||||
ShellyButtonDescription[ShellyBlockCoordinator](
|
ShellyButtonDescription[ShellyBlockCoordinator](
|
||||||
key="self_test",
|
key="self_test",
|
||||||
name="Self test",
|
name="Self test",
|
||||||
icon="mdi:progress-wrench",
|
translation_key="self_test",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
press_action=lambda coordinator: coordinator.device.trigger_shelly_gas_self_test(),
|
press_action=lambda coordinator: coordinator.device.trigger_shelly_gas_self_test(),
|
||||||
supported=lambda coordinator: coordinator.device.model in SHELLY_GAS_MODELS,
|
supported=lambda coordinator: coordinator.device.model in SHELLY_GAS_MODELS,
|
||||||
@ -66,7 +66,7 @@ BUTTONS: Final[list[ShellyButtonDescription[Any]]] = [
|
|||||||
ShellyButtonDescription[ShellyBlockCoordinator](
|
ShellyButtonDescription[ShellyBlockCoordinator](
|
||||||
key="mute",
|
key="mute",
|
||||||
name="Mute",
|
name="Mute",
|
||||||
icon="mdi:volume-mute",
|
translation_key="mute",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
press_action=lambda coordinator: coordinator.device.trigger_shelly_gas_mute(),
|
press_action=lambda coordinator: coordinator.device.trigger_shelly_gas_mute(),
|
||||||
supported=lambda coordinator: coordinator.device.model in SHELLY_GAS_MODELS,
|
supported=lambda coordinator: coordinator.device.model in SHELLY_GAS_MODELS,
|
||||||
@ -74,7 +74,7 @@ BUTTONS: Final[list[ShellyButtonDescription[Any]]] = [
|
|||||||
ShellyButtonDescription[ShellyBlockCoordinator](
|
ShellyButtonDescription[ShellyBlockCoordinator](
|
||||||
key="unmute",
|
key="unmute",
|
||||||
name="Unmute",
|
name="Unmute",
|
||||||
icon="mdi:volume-high",
|
translation_key="unmute",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
press_action=lambda coordinator: coordinator.device.trigger_shelly_gas_unmute(),
|
press_action=lambda coordinator: coordinator.device.trigger_shelly_gas_unmute(),
|
||||||
supported=lambda coordinator: coordinator.device.model in SHELLY_GAS_MODELS,
|
supported=lambda coordinator: coordinator.device.model in SHELLY_GAS_MODELS,
|
||||||
|
@ -156,7 +156,6 @@ class BlockSleepingClimate(
|
|||||||
"""Representation of a Shelly climate device."""
|
"""Representation of a Shelly climate device."""
|
||||||
|
|
||||||
_attr_hvac_modes = [HVACMode.OFF, HVACMode.HEAT]
|
_attr_hvac_modes = [HVACMode.OFF, HVACMode.HEAT]
|
||||||
_attr_icon = "mdi:thermostat"
|
|
||||||
_attr_max_temp = SHTRV_01_TEMPERATURE_SETTINGS["max"]
|
_attr_max_temp = SHTRV_01_TEMPERATURE_SETTINGS["max"]
|
||||||
_attr_min_temp = SHTRV_01_TEMPERATURE_SETTINGS["min"]
|
_attr_min_temp = SHTRV_01_TEMPERATURE_SETTINGS["min"]
|
||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
@ -439,7 +438,6 @@ class BlockSleepingClimate(
|
|||||||
class RpcClimate(ShellyRpcEntity, ClimateEntity):
|
class RpcClimate(ShellyRpcEntity, ClimateEntity):
|
||||||
"""Entity that controls a thermostat on RPC based Shelly devices."""
|
"""Entity that controls a thermostat on RPC based Shelly devices."""
|
||||||
|
|
||||||
_attr_icon = "mdi:thermostat"
|
|
||||||
_attr_max_temp = RPC_THERMOSTAT_SETTINGS["max"]
|
_attr_max_temp = RPC_THERMOSTAT_SETTINGS["max"]
|
||||||
_attr_min_temp = RPC_THERMOSTAT_SETTINGS["min"]
|
_attr_min_temp = RPC_THERMOSTAT_SETTINGS["min"]
|
||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
|
@ -273,7 +273,6 @@ class BlockEntityDescription(EntityDescription):
|
|||||||
# restrict the type to str.
|
# restrict the type to str.
|
||||||
name: str = ""
|
name: str = ""
|
||||||
|
|
||||||
icon_fn: Callable[[dict], str] | None = None
|
|
||||||
unit_fn: Callable[[dict], str] | None = None
|
unit_fn: Callable[[dict], str] | None = None
|
||||||
value: Callable[[Any], Any] = lambda val: val
|
value: Callable[[Any], Any] = lambda val: val
|
||||||
available: Callable[[Block], bool] | None = None
|
available: Callable[[Block], bool] | None = None
|
||||||
|
46
homeassistant/components/shelly/icons.json
Normal file
46
homeassistant/components/shelly/icons.json
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"entity": {
|
||||||
|
"button": {
|
||||||
|
"mute": {
|
||||||
|
"default": "mdi:volume-mute"
|
||||||
|
},
|
||||||
|
"self_test": {
|
||||||
|
"default": "mdi:progress-wrench"
|
||||||
|
},
|
||||||
|
"unmute": {
|
||||||
|
"default": "mdi:volume-high"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"number": {
|
||||||
|
"valve_position": {
|
||||||
|
"default": "mdi:pipe-valve"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sensor": {
|
||||||
|
"gas_concentration": {
|
||||||
|
"default": "mdi:gauge"
|
||||||
|
},
|
||||||
|
"lamp_life": {
|
||||||
|
"default": "mdi:progress-wrench"
|
||||||
|
},
|
||||||
|
"operation": {
|
||||||
|
"default": "mdi:cog-transfer"
|
||||||
|
},
|
||||||
|
"tilt": {
|
||||||
|
"default": "mdi:angle-acute"
|
||||||
|
},
|
||||||
|
"valve_status": {
|
||||||
|
"default": "mdi:valve"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"switch": {
|
||||||
|
"valve_switch": {
|
||||||
|
"default": "mdi:valve",
|
||||||
|
"state": {
|
||||||
|
"off": "mdi:valve-closed",
|
||||||
|
"on": "mdi:valve-open"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -40,7 +40,7 @@ class BlockNumberDescription(BlockEntityDescription, NumberEntityDescription):
|
|||||||
NUMBERS: dict[tuple[str, str], BlockNumberDescription] = {
|
NUMBERS: dict[tuple[str, str], BlockNumberDescription] = {
|
||||||
("device", "valvePos"): BlockNumberDescription(
|
("device", "valvePos"): BlockNumberDescription(
|
||||||
key="device|valvepos",
|
key="device|valvepos",
|
||||||
icon="mdi:pipe-valve",
|
translation_key="valve_position",
|
||||||
name="Valve position",
|
name="Valve position",
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
available=lambda block: cast(int, block.valveError) != 1,
|
available=lambda block: cast(int, block.valveError) != 1,
|
||||||
|
@ -235,7 +235,7 @@ SENSORS: dict[tuple[str, str], BlockSensorDescription] = {
|
|||||||
key="sensor|concentration",
|
key="sensor|concentration",
|
||||||
name="Gas concentration",
|
name="Gas concentration",
|
||||||
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
|
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
|
||||||
icon="mdi:gauge",
|
translation_key="gas_concentration",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
("sensor", "temp"): BlockSensorDescription(
|
("sensor", "temp"): BlockSensorDescription(
|
||||||
@ -279,14 +279,14 @@ SENSORS: dict[tuple[str, str], BlockSensorDescription] = {
|
|||||||
key="sensor|tilt",
|
key="sensor|tilt",
|
||||||
name="Tilt",
|
name="Tilt",
|
||||||
native_unit_of_measurement=DEGREE,
|
native_unit_of_measurement=DEGREE,
|
||||||
icon="mdi:angle-acute",
|
translation_key="tilt",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
("relay", "totalWorkTime"): BlockSensorDescription(
|
("relay", "totalWorkTime"): BlockSensorDescription(
|
||||||
key="relay|totalWorkTime",
|
key="relay|totalWorkTime",
|
||||||
name="Lamp life",
|
name="Lamp life",
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
icon="mdi:progress-wrench",
|
translation_key="lamp_life",
|
||||||
value=lambda value: 100 - (value / 3600 / SHAIR_MAX_WORK_HOURS),
|
value=lambda value: 100 - (value / 3600 / SHAIR_MAX_WORK_HOURS),
|
||||||
suggested_display_precision=1,
|
suggested_display_precision=1,
|
||||||
extra_state_attributes=lambda block: {
|
extra_state_attributes=lambda block: {
|
||||||
@ -308,7 +308,6 @@ SENSORS: dict[tuple[str, str], BlockSensorDescription] = {
|
|||||||
device_class=SensorDeviceClass.ENUM,
|
device_class=SensorDeviceClass.ENUM,
|
||||||
options=["unknown", "warmup", "normal", "fault"],
|
options=["unknown", "warmup", "normal", "fault"],
|
||||||
translation_key="operation",
|
translation_key="operation",
|
||||||
icon="mdi:cog-transfer",
|
|
||||||
value=lambda value: value,
|
value=lambda value: value,
|
||||||
extra_state_attributes=lambda block: {"self_test": block.selfTest},
|
extra_state_attributes=lambda block: {"self_test": block.selfTest},
|
||||||
),
|
),
|
||||||
@ -316,7 +315,6 @@ SENSORS: dict[tuple[str, str], BlockSensorDescription] = {
|
|||||||
key="valve|valve",
|
key="valve|valve",
|
||||||
name="Valve status",
|
name="Valve status",
|
||||||
translation_key="valve_status",
|
translation_key="valve_status",
|
||||||
icon="mdi:valve",
|
|
||||||
device_class=SensorDeviceClass.ENUM,
|
device_class=SensorDeviceClass.ENUM,
|
||||||
options=[
|
options=[
|
||||||
"checking",
|
"checking",
|
||||||
|
@ -153,6 +153,7 @@ class BlockValveSwitch(ShellyBlockAttributeEntity, SwitchEntity):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
entity_description: BlockSwitchDescription
|
entity_description: BlockSwitchDescription
|
||||||
|
_attr_translation_key = "valve_switch"
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -173,11 +174,6 @@ class BlockValveSwitch(ShellyBlockAttributeEntity, SwitchEntity):
|
|||||||
|
|
||||||
return self.attribute_value in GAS_VALVE_OPEN_STATES
|
return self.attribute_value in GAS_VALVE_OPEN_STATES
|
||||||
|
|
||||||
@property
|
|
||||||
def icon(self) -> str:
|
|
||||||
"""Return the icon."""
|
|
||||||
return "mdi:valve-open" if self.is_on else "mdi:valve-closed"
|
|
||||||
|
|
||||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Open valve."""
|
"""Open valve."""
|
||||||
async_create_issue(
|
async_create_issue(
|
||||||
|
@ -15,7 +15,6 @@ from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
|||||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState
|
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID,
|
ATTR_ENTITY_ID,
|
||||||
ATTR_ICON,
|
|
||||||
SERVICE_TURN_OFF,
|
SERVICE_TURN_OFF,
|
||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
@ -290,7 +289,6 @@ async def test_block_device_gas_valve(
|
|||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
assert state
|
assert state
|
||||||
assert state.state == STATE_ON # valve is open
|
assert state.state == STATE_ON # valve is open
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:valve-open"
|
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
SWITCH_DOMAIN,
|
SWITCH_DOMAIN,
|
||||||
@ -302,7 +300,6 @@ async def test_block_device_gas_valve(
|
|||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
assert state
|
assert state
|
||||||
assert state.state == STATE_OFF # valve is closed
|
assert state.state == STATE_OFF # valve is closed
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:valve-closed"
|
|
||||||
|
|
||||||
monkeypatch.setattr(mock_block_device.blocks[GAS_VALVE_BLOCK_ID], "valve", "opened")
|
monkeypatch.setattr(mock_block_device.blocks[GAS_VALVE_BLOCK_ID], "valve", "opened")
|
||||||
mock_block_device.mock_update()
|
mock_block_device.mock_update()
|
||||||
@ -311,7 +308,6 @@ async def test_block_device_gas_valve(
|
|||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
assert state
|
assert state
|
||||||
assert state.state == STATE_ON # valve is open
|
assert state.state == STATE_ON # valve is open
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:valve-open"
|
|
||||||
|
|
||||||
|
|
||||||
async def test_wall_display_thermostat_mode(
|
async def test_wall_display_thermostat_mode(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user