Skip to content

Commit

Permalink
Add icon translations support (home-assistant#103294)
Browse files Browse the repository at this point in the history
Co-authored-by: Robert Resch <[email protected]>
Co-authored-by: Paul Bottein <[email protected]>
  • Loading branch information
3 people authored Jan 19, 2024
1 parent ed449a5 commit 0137202
Show file tree
Hide file tree
Showing 21 changed files with 886 additions and 53 deletions.
178 changes: 178 additions & 0 deletions homeassistant/components/binary_sensor/icons.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
{
"entity_component": {
"_": {
"default": "mdi:radiobox-blank",
"state": {
"on": "mdi:checkbox-marked-circle"
}
},
"battery": {
"default": "mdi:battery",
"state": {
"on": "mdi:battery-outline"
}
},
"battery_charging": {
"default": "mdi:battery",
"state": {
"on": "mdi:battery-charging"
}
},
"carbon_monoxide": {
"default": "mdi:smoke-detector",
"state": {
"on": "mdi:smoke-detector-alert"
}
},
"cold": {
"default": "mdi:thermometer",
"state": {
"on": "mdi:snowflake"
}
},
"connectivity": {
"default": "mdi:close-network-outline",
"state": {
"on": "mdi:check-network-outline"
}
},
"door": {
"default": "mdi:door-closed",
"state": {
"on": "mdi:door-open"
}
},
"garage_door": {
"default": "mdi:garage",
"state": {
"on": "mdi:garage-open"
}
},
"gas": {
"default": "mdi:check-circle",
"state": {
"on": "mdi:alert-circle"
}
},
"heat": {
"default": "mdi:thermometer",
"state": {
"on": "mdi:fire"
}
},
"light": {
"default": "mdi:brightness-5",
"state": {
"on": "mdi:brightness-7"
}
},
"lock": {
"default": "mdi:lock",
"state": {
"on": "mdi:lock-open"
}
},
"moisture": {
"default": "mdi:water-off",
"state": {
"on": "mdi:water"
}
},
"motion": {
"default": "mdi:motion-sensor-off",
"state": {
"on": "mdi:motion-sensor"
}
},
"moving": {
"default": "mdi:arrow-right",
"state": {
"on": "mdi:octagon"
}
},
"occupancy": {
"default": "mdi:home-outline",
"state": {
"on": "mdi:home"
}
},
"opening": {
"default": "mdi:square",
"state": {
"on": "mdi:square-outline"
}
},
"plug": {
"default": "mdi:power-plug-off",
"state": {
"on": "mdi:power-plug"
}
},
"power": {
"default": "mdi:power-plug-off",
"state": {
"on": "mdi:power-plug"
}
},
"presence": {
"default": "mdi:home-outline",
"state": {
"on": "mdi:home"
}
},
"problem": {
"default": "mdi:check-circle",
"state": {
"on": "mdi:alert-circle"
}
},
"running": {
"default": "mdi:stop",
"state": {
"on": "mdi:play"
}
},
"safety": {
"default": "mdi:check-circle",
"state": {
"on": "mdi:alert-circle"
}
},
"smoke": {
"default": "mdi:smoke-detector-variant",
"state": {
"on": "mdi:smoke-detector-variant-alert"
}
},
"sound": {
"default": "mdi:music-note-off",
"state": {
"on": "mdi:music-note"
}
},
"tamper": {
"default": "mdi:check-circle",
"state": {
"on": "mdi:alert-circle"
}
},
"update": {
"default": "mdi:package",
"state": {
"on": "mdi:package-up"
}
},
"vibration": {
"default": "mdi:crop-portrait",
"state": {
"on": "mdi:vibrate"
}
},
"window": {
"default": "mdi:window-closed",
"state": {
"on": "mdi:window-open"
}
}
}
}
62 changes: 62 additions & 0 deletions homeassistant/components/demo/icons.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"entity": {
"climate": {
"ubercool": {
"state_attributes": {
"fan_mode": {
"state": {
"auto_high": "mdi:fan-auto",
"auto_low": "mdi:fan-auto",
"on_high": "mdi:fan-chevron-up",
"on_low": "mdi:fan-chevron-down"
}
},
"swing_mode": {
"state": {
"1": "mdi:numeric-1",
"2": "mdi:numeric-2",
"3": "mdi:numeric-3",
"auto": "mdi:arrow-oscillating",
"off": "mdi:arrow-oscillating-off"
}
}
}
}
},
"number": {
"volume": {
"default": "mdi:volume-high"
},
"pwm": {
"default": "mdi:square-wave"
},
"range": {
"default": "mdi:square-wave"
}
},
"select": {
"speed": {
"state": {
"light_speed": "mdi:speedometer-slow",
"ludicrous_speed": "mdi:speedometer-medium",
"ridiculous_speed": "mdi:speedometer"
}
}
},
"sensor": {
"thermostat_mode": {
"state": {
"away": "mdi:home-export-outline",
"comfort": "mdi:home-account",
"eco": "mdi:leaf",
"sleep": "mdi:weather-night"
}
}
},
"switch": {
"air_conditioner": {
"default": "mdi:air-conditioner"
}
}
}
}
14 changes: 7 additions & 7 deletions homeassistant/components/demo/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ async def async_setup_entry(
"volume1",
"volume",
42.0,
"mdi:volume-high",
"volume",
False,
mode=NumberMode.SLIDER,
),
DemoNumber(
"pwm1",
"PWM 1",
0.42,
"mdi:square-wave",
"pwm",
False,
native_min_value=0.0,
native_max_value=1.0,
Expand All @@ -42,7 +42,7 @@ async def async_setup_entry(
"large_range",
"Large Range",
500,
"mdi:square-wave",
"range",
False,
native_min_value=1,
native_max_value=1000,
Expand All @@ -52,7 +52,7 @@ async def async_setup_entry(
"small_range",
"Small Range",
128,
"mdi:square-wave",
"range",
False,
native_min_value=1,
native_max_value=255,
Expand All @@ -62,7 +62,7 @@ async def async_setup_entry(
"temp1",
"Temperature setting",
22,
"mdi:thermometer",
None,
False,
device_class=NumberDeviceClass.TEMPERATURE,
native_min_value=15.0,
Expand All @@ -87,7 +87,7 @@ def __init__(
unique_id: str,
device_name: str,
state: float,
icon: str,
translation_key: str | None,
assumed_state: bool,
*,
device_class: NumberDeviceClass | None = None,
Expand All @@ -100,7 +100,7 @@ def __init__(
"""Initialize the Demo Number entity."""
self._attr_assumed_state = assumed_state
self._attr_device_class = device_class
self._attr_icon = icon
self._attr_translation_key = translation_key
self._attr_mode = mode
self._attr_native_unit_of_measurement = unit_of_measurement
self._attr_native_value = state
Expand Down
7 changes: 3 additions & 4 deletions homeassistant/components/demo/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ async def async_setup_entry(
"""Set up the Demo config entry."""
async_add_entities(
[
DemoRemote("Remote One", False, None),
DemoRemote("Remote Two", True, "mdi:remote"),
DemoRemote("Remote One", False),
DemoRemote("Remote Two", True),
]
)

Expand All @@ -30,11 +30,10 @@ class DemoRemote(RemoteEntity):

_attr_should_poll = False

def __init__(self, name: str | None, state: bool, icon: str | None) -> None:
def __init__(self, name: str | None, state: bool) -> None:
"""Initialize the Demo Remote."""
self._attr_name = name or DEVICE_DEFAULT_NAME
self._attr_is_on = state
self._attr_icon = icon
self._last_command_sent: str | None = None

@property
Expand Down
3 changes: 0 additions & 3 deletions homeassistant/components/demo/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ async def async_setup_entry(
DemoSelect(
unique_id="speed",
device_name="Speed",
icon="mdi:speedometer",
current_option="ridiculous_speed",
options=[
"light_speed",
Expand All @@ -45,15 +44,13 @@ def __init__(
self,
unique_id: str,
device_name: str,
icon: str,
current_option: str | None,
options: list[str],
translation_key: str,
) -> None:
"""Initialize the Demo select entity."""
self._attr_unique_id = unique_id
self._attr_current_option = current_option
self._attr_icon = icon
self._attr_options = options
self._attr_translation_key = translation_key
self._attr_device_info = DeviceInfo(
Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/demo/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ async def async_setup_entry(
"""Set up the demo switch platform."""
async_add_entities(
[
DemoSwitch("switch1", "Decorative Lights", True, None, True),
DemoSwitch("switch1", "Decorative Lights", True, True),
DemoSwitch(
"switch2",
"AC",
False,
"mdi:air-conditioner",
False,
translation_key="air_conditioner",
device_class=SwitchDeviceClass.OUTLET,
),
]
Expand All @@ -45,14 +45,14 @@ def __init__(
unique_id: str,
device_name: str,
state: bool,
icon: str | None,
assumed: bool,
translation_key: str | None = None,
device_class: SwitchDeviceClass | None = None,
) -> None:
"""Initialize the Demo switch."""
self._attr_assumed_state = assumed
self._attr_device_class = device_class
self._attr_icon = icon
self._attr_translation_key = translation_key
self._attr_is_on = state
self._attr_unique_id = unique_id
self._attr_device_info = DeviceInfo(
Expand Down
Loading

0 comments on commit 0137202

Please sign in to comment.