mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Add icon translations to Moon (#111386)
This commit is contained in:
parent
86607d2bbb
commit
13cd6eb00e
19
homeassistant/components/moon/icons.json
Normal file
19
homeassistant/components/moon/icons.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"phase": {
|
||||
"default": "mdi:weather-night",
|
||||
"state": {
|
||||
"first_quarter": "mdi:moon-first-quarter",
|
||||
"full_moon": "mdi:moon-full",
|
||||
"last_quarter": "mdi:moon-last-quarter",
|
||||
"new_moon": "mdi:moon-new",
|
||||
"waning_crescent": "mdi:moon-waning-crescent",
|
||||
"waning_gibbous": "mdi:moon-waning-gibbous",
|
||||
"waxing_crescent": "mdi:moon-waxing-crescent",
|
||||
"waxing_gibbous": "mdi:moon-waxing-gibbous"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -22,17 +22,6 @@ STATE_WANING_GIBBOUS = "waning_gibbous"
|
||||
STATE_WAXING_CRESCENT = "waxing_crescent"
|
||||
STATE_WAXING_GIBBOUS = "waxing_gibbous"
|
||||
|
||||
MOON_ICONS = {
|
||||
STATE_FIRST_QUARTER: "mdi:moon-first-quarter",
|
||||
STATE_FULL_MOON: "mdi:moon-full",
|
||||
STATE_LAST_QUARTER: "mdi:moon-last-quarter",
|
||||
STATE_NEW_MOON: "mdi:moon-new",
|
||||
STATE_WANING_CRESCENT: "mdi:moon-waning-crescent",
|
||||
STATE_WANING_GIBBOUS: "mdi:moon-waning-gibbous",
|
||||
STATE_WAXING_CRESCENT: "mdi:moon-waxing-crescent",
|
||||
STATE_WAXING_GIBBOUS: "mdi:moon-waxing-gibbous",
|
||||
}
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
@ -90,5 +79,3 @@ class MoonSensorEntity(SensorEntity):
|
||||
self._attr_native_value = STATE_LAST_QUARTER
|
||||
else:
|
||||
self._attr_native_value = STATE_WANING_CRESCENT
|
||||
|
||||
self._attr_icon = MOON_ICONS.get(self._attr_native_value)
|
||||
|
@ -7,7 +7,6 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.moon.sensor import (
|
||||
MOON_ICONS,
|
||||
STATE_FIRST_QUARTER,
|
||||
STATE_FULL_MOON,
|
||||
STATE_LAST_QUARTER,
|
||||
@ -18,7 +17,7 @@ from homeassistant.components.moon.sensor import (
|
||||
STATE_WAXING_GIBBOUS,
|
||||
)
|
||||
from homeassistant.components.sensor import ATTR_OPTIONS, SensorDeviceClass
|
||||
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_FRIENDLY_NAME, ATTR_ICON
|
||||
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_FRIENDLY_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
@ -26,16 +25,16 @@ from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("moon_value", "native_value", "icon"),
|
||||
("moon_value", "native_value"),
|
||||
[
|
||||
(0, STATE_NEW_MOON, MOON_ICONS[STATE_NEW_MOON]),
|
||||
(5, STATE_WAXING_CRESCENT, MOON_ICONS[STATE_WAXING_CRESCENT]),
|
||||
(7, STATE_FIRST_QUARTER, MOON_ICONS[STATE_FIRST_QUARTER]),
|
||||
(12, STATE_WAXING_GIBBOUS, MOON_ICONS[STATE_WAXING_GIBBOUS]),
|
||||
(14.3, STATE_FULL_MOON, MOON_ICONS[STATE_FULL_MOON]),
|
||||
(20.1, STATE_WANING_GIBBOUS, MOON_ICONS[STATE_WANING_GIBBOUS]),
|
||||
(20.8, STATE_LAST_QUARTER, MOON_ICONS[STATE_LAST_QUARTER]),
|
||||
(23, STATE_WANING_CRESCENT, MOON_ICONS[STATE_WANING_CRESCENT]),
|
||||
(0, STATE_NEW_MOON),
|
||||
(5, STATE_WAXING_CRESCENT),
|
||||
(7, STATE_FIRST_QUARTER),
|
||||
(12, STATE_WAXING_GIBBOUS),
|
||||
(14.3, STATE_FULL_MOON),
|
||||
(20.1, STATE_WANING_GIBBOUS),
|
||||
(20.8, STATE_LAST_QUARTER),
|
||||
(23, STATE_WANING_CRESCENT),
|
||||
],
|
||||
)
|
||||
async def test_moon_day(
|
||||
@ -45,7 +44,6 @@ async def test_moon_day(
|
||||
mock_config_entry: MockConfigEntry,
|
||||
moon_value: float,
|
||||
native_value: str,
|
||||
icon: str,
|
||||
) -> None:
|
||||
"""Test the Moon sensor."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@ -59,7 +57,6 @@ async def test_moon_day(
|
||||
state = hass.states.get("sensor.moon_phase")
|
||||
assert state
|
||||
assert state.state == native_value
|
||||
assert state.attributes[ATTR_ICON] == icon
|
||||
assert state.attributes[ATTR_FRIENDLY_NAME] == "Moon Phase"
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.ENUM
|
||||
assert state.attributes[ATTR_OPTIONS] == [
|
||||
|
Loading…
x
Reference in New Issue
Block a user