mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 22:37:11 +00:00
Add icon translations to Modern Forms (#111933)
* Add icon translations to Modern Forms * Add icon translations to Modern Forms
This commit is contained in:
parent
fbb982f8ce
commit
4ae7102f63
@ -139,14 +139,12 @@ class ModernFormsDeviceEntity(CoordinatorEntity[ModernFormsDataUpdateCoordinator
|
||||
*,
|
||||
entry_id: str,
|
||||
coordinator: ModernFormsDataUpdateCoordinator,
|
||||
icon: str | None = None,
|
||||
enabled_default: bool = True,
|
||||
) -> None:
|
||||
"""Initialize the Modern Forms entity."""
|
||||
super().__init__(coordinator)
|
||||
self._attr_enabled_default = enabled_default
|
||||
self._entry_id = entry_id
|
||||
self._attr_icon = icon
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
|
@ -40,11 +40,10 @@ class ModernFormsBinarySensor(ModernFormsDeviceEntity, BinarySensorEntity):
|
||||
*,
|
||||
entry_id: str,
|
||||
coordinator: ModernFormsDataUpdateCoordinator,
|
||||
icon: str,
|
||||
key: str,
|
||||
) -> None:
|
||||
"""Initialize Modern Forms switch."""
|
||||
super().__init__(entry_id=entry_id, coordinator=coordinator, icon=icon)
|
||||
super().__init__(entry_id=entry_id, coordinator=coordinator)
|
||||
|
||||
self._attr_unique_id = f"{coordinator.data.info.mac_address}_{key}"
|
||||
|
||||
@ -62,7 +61,6 @@ class ModernFormsLightSleepTimerActive(ModernFormsBinarySensor):
|
||||
super().__init__(
|
||||
coordinator=coordinator,
|
||||
entry_id=entry_id,
|
||||
icon="mdi:av-timer",
|
||||
key="light_sleep_timer_active",
|
||||
)
|
||||
|
||||
@ -94,7 +92,6 @@ class ModernFormsFanSleepTimerActive(ModernFormsBinarySensor):
|
||||
super().__init__(
|
||||
coordinator=coordinator,
|
||||
entry_id=entry_id,
|
||||
icon="mdi:av-timer",
|
||||
key="fan_sleep_timer_active",
|
||||
)
|
||||
|
||||
|
34
homeassistant/components/modern_forms/icons.json
Normal file
34
homeassistant/components/modern_forms/icons.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"light_sleep_timer_active": {
|
||||
"default": "mdi:av-timer"
|
||||
},
|
||||
"fan_sleep_timer_active": {
|
||||
"default": "mdi:av-timer"
|
||||
}
|
||||
},
|
||||
"sensor": {
|
||||
"light_timer_remaining_time": {
|
||||
"default": "mdi:timer-outline"
|
||||
},
|
||||
"fan_timer_remaining_time": {
|
||||
"default": "mdi:timer-outline"
|
||||
}
|
||||
},
|
||||
"switch": {
|
||||
"away_mode": {
|
||||
"default": "mdi:airplane-takeoff"
|
||||
},
|
||||
"adaptive_learning": {
|
||||
"default": "mdi:school-outline"
|
||||
}
|
||||
}
|
||||
},
|
||||
"services": {
|
||||
"set_light_sleep_timer": "mdi:timer",
|
||||
"clear_light_sleep_timer": "mdi:timer-cancel",
|
||||
"set_fan_sleep_timer": "mdi:timer",
|
||||
"clear_fan_sleep_timer": "mdi:timer-cancel"
|
||||
}
|
||||
}
|
@ -90,7 +90,6 @@ class ModernFormsLightEntity(ModernFormsDeviceEntity, LightEntity):
|
||||
super().__init__(
|
||||
entry_id=entry_id,
|
||||
coordinator=coordinator,
|
||||
icon=None,
|
||||
)
|
||||
self._attr_unique_id = f"{self.coordinator.data.info.mac_address}"
|
||||
|
||||
|
@ -43,12 +43,11 @@ class ModernFormsSensor(ModernFormsDeviceEntity, SensorEntity):
|
||||
*,
|
||||
entry_id: str,
|
||||
coordinator: ModernFormsDataUpdateCoordinator,
|
||||
icon: str,
|
||||
key: str,
|
||||
) -> None:
|
||||
"""Initialize Modern Forms switch."""
|
||||
self._key = key
|
||||
super().__init__(entry_id=entry_id, coordinator=coordinator, icon=icon)
|
||||
super().__init__(entry_id=entry_id, coordinator=coordinator)
|
||||
self._attr_unique_id = f"{self.coordinator.data.info.mac_address}_{self._key}"
|
||||
|
||||
|
||||
@ -64,7 +63,6 @@ class ModernFormsLightTimerRemainingTimeSensor(ModernFormsSensor):
|
||||
super().__init__(
|
||||
coordinator=coordinator,
|
||||
entry_id=entry_id,
|
||||
icon="mdi:timer-outline",
|
||||
key="light_timer_remaining_time",
|
||||
)
|
||||
self._attr_device_class = SensorDeviceClass.TIMESTAMP
|
||||
@ -95,7 +93,6 @@ class ModernFormsFanTimerRemainingTimeSensor(ModernFormsSensor):
|
||||
super().__init__(
|
||||
coordinator=coordinator,
|
||||
entry_id=entry_id,
|
||||
icon="mdi:timer-outline",
|
||||
key="fan_timer_remaining_time",
|
||||
)
|
||||
self._attr_device_class = SensorDeviceClass.TIMESTAMP
|
||||
|
@ -39,12 +39,11 @@ class ModernFormsSwitch(ModernFormsDeviceEntity, SwitchEntity):
|
||||
*,
|
||||
entry_id: str,
|
||||
coordinator: ModernFormsDataUpdateCoordinator,
|
||||
icon: str,
|
||||
key: str,
|
||||
) -> None:
|
||||
"""Initialize Modern Forms switch."""
|
||||
self._key = key
|
||||
super().__init__(entry_id=entry_id, coordinator=coordinator, icon=icon)
|
||||
super().__init__(entry_id=entry_id, coordinator=coordinator)
|
||||
self._attr_unique_id = f"{self.coordinator.data.info.mac_address}_{self._key}"
|
||||
|
||||
|
||||
@ -60,7 +59,6 @@ class ModernFormsAwaySwitch(ModernFormsSwitch):
|
||||
super().__init__(
|
||||
coordinator=coordinator,
|
||||
entry_id=entry_id,
|
||||
icon="mdi:airplane-takeoff",
|
||||
key="away_mode",
|
||||
)
|
||||
|
||||
@ -92,7 +90,6 @@ class ModernFormsAdaptiveLearningSwitch(ModernFormsSwitch):
|
||||
super().__init__(
|
||||
coordinator=coordinator,
|
||||
entry_id=entry_id,
|
||||
icon="mdi:school-outline",
|
||||
key="adaptive_learning",
|
||||
)
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
"""Tests for the Modern Forms sensor platform."""
|
||||
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
||||
from homeassistant.components.modern_forms.const import DOMAIN
|
||||
from homeassistant.const import ATTR_ICON
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
@ -37,11 +36,9 @@ async def test_binary_sensors(
|
||||
# Light timer remaining time
|
||||
state = hass.states.get("binary_sensor.modernformsfan_light_sleep_timer_active")
|
||||
assert state
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:av-timer"
|
||||
assert state.state == "off"
|
||||
|
||||
# Fan timer remaining time
|
||||
state = hass.states.get("binary_sensor.modernformsfan_fan_sleep_timer_active")
|
||||
assert state
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:av-timer"
|
||||
assert state.state == "off"
|
||||
|
@ -2,7 +2,7 @@
|
||||
from datetime import datetime
|
||||
|
||||
from homeassistant.components.sensor import SensorDeviceClass
|
||||
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_ICON
|
||||
from homeassistant.const import ATTR_DEVICE_CLASS
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import init_integration, modern_forms_timers_set_mock
|
||||
@ -21,14 +21,12 @@ async def test_sensors(
|
||||
# Light timer remaining time
|
||||
state = hass.states.get("sensor.modernformsfan_light_sleep_time")
|
||||
assert state
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:timer-outline"
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.TIMESTAMP
|
||||
assert state.state == "unknown"
|
||||
|
||||
# Fan timer remaining time
|
||||
state = hass.states.get("sensor.modernformsfan_fan_sleep_time")
|
||||
assert state
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:timer-outline"
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.TIMESTAMP
|
||||
assert state.state == "unknown"
|
||||
|
||||
@ -44,13 +42,11 @@ async def test_active_sensors(
|
||||
# Light timer remaining time
|
||||
state = hass.states.get("sensor.modernformsfan_light_sleep_time")
|
||||
assert state
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:timer-outline"
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.TIMESTAMP
|
||||
datetime.fromisoformat(state.state)
|
||||
|
||||
# Fan timer remaining time
|
||||
state = hass.states.get("sensor.modernformsfan_fan_sleep_time")
|
||||
assert state
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:timer-outline"
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.TIMESTAMP
|
||||
datetime.fromisoformat(state.state)
|
||||
|
@ -7,7 +7,6 @@ import pytest
|
||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
ATTR_ICON,
|
||||
SERVICE_TURN_OFF,
|
||||
SERVICE_TURN_ON,
|
||||
STATE_OFF,
|
||||
@ -31,7 +30,6 @@ async def test_switch_state(
|
||||
|
||||
state = hass.states.get("switch.modernformsfan_away_mode")
|
||||
assert state
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:airplane-takeoff"
|
||||
assert state.state == STATE_OFF
|
||||
|
||||
entry = entity_registry.async_get("switch.modernformsfan_away_mode")
|
||||
@ -40,7 +38,6 @@ async def test_switch_state(
|
||||
|
||||
state = hass.states.get("switch.modernformsfan_adaptive_learning")
|
||||
assert state
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:school-outline"
|
||||
assert state.state == STATE_OFF
|
||||
|
||||
entry = entity_registry.async_get("switch.modernformsfan_adaptive_learning")
|
||||
|
Loading…
x
Reference in New Issue
Block a user