Skip to content

Commit

Permalink
Merge pull request #56 from theneweinstein/icons
Browse files Browse the repository at this point in the history
Icons
  • Loading branch information
theneweinstein authored Feb 23, 2024
2 parents 157e1c4 + b5e731f commit 78743cd
Show file tree
Hide file tree
Showing 15 changed files with 229 additions and 1,842 deletions.
2 changes: 1 addition & 1 deletion .devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ludeeus/integration_blueprint",
"image": "mcr.microsoft.com/vscode/devcontainers/python:3.11",
"image": "mcr.microsoft.com/vscode/devcontainers/python:3.12",
"postCreateCommand": "scripts/setup",
"forwardPorts": [
8123
Expand Down
4 changes: 1 addition & 3 deletions custom_components/somneo/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import DISMISS_ICON, DOMAIN, SNOOZE_ICON
from .const import DOMAIN
from .entity import SomneoEntity

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -37,7 +37,6 @@ async def async_setup_entry(
class SomneoDismiss(SomneoEntity, ButtonEntity):
"""Dismiss alarm button."""

_attr_icon = DISMISS_ICON
_attr_should_poll = True
_attr_translation_key = "alarm_dismiss"

Expand All @@ -49,7 +48,6 @@ async def async_press(self) -> None:
class SomneoSnooze(SomneoEntity, ButtonEntity):
"""Snooze alarm button."""

_attr_icon = SNOOZE_ICON
_attr_should_poll = True
_attr_translation_key = "alarm_snooze"

Expand Down
11 changes: 0 additions & 11 deletions custom_components/somneo/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
)

DOMAIN: Final = "somneo"
VERSION: Final = "0.3"

DEFAULT_NAME: Final = "Somneo"

Expand All @@ -28,23 +27,13 @@
CUSTOM: Final = "custom"
PW_DELTA: Final = "powerwake_delta"

ALARMS_ICON: Final = "hass:alarm"
DISMISS_ICON: Final = "hass:alarm-off"
PW_ICON: Final = "hass:alarm-plus"
TIME_ICON: Final = "hass:clock-digital"
SNOOZE_ICON: Final = "hass:alarm-snooze"
WORKDAYS_ICON: Final = "hass:calendar-range"
WEEKEND_ICON: Final = "hass:calendar-range"
SUNSET_ICON: Final = "hass:weather-sunset"

ATTR_ALARM: Final = "alarm"
ATTR_CURVE: Final = "curve"
ATTR_LEVEL: Final = "level"
ATTR_DURATION: Final = "duration"
ATTR_SOURCE: Final = "source"
ATTR_CHANNEL: Final = "channel"


SENSORS: Final = {
"temperature": UnitOfTemperature.CELSIUS,
"humidity": PERCENTAGE,
Expand Down
132 changes: 132 additions & 0 deletions custom_components/somneo/icons.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"entity": {
"button": {
"alarm_dismiss": {
"default": "mdi:alarm-off"
},
"alarm_snooze": {
"default": "mdi:alarm-snooze"
}
},
"light": {
"normal_light": {
"default": "mdi:lightbulb"
},
"night_light": {
"default": "mdi:lightbulb-night"
}
},
"number": {
"powerwake_delta": {
"default": "mdi:clock-start"
},
"snooze_time": {
"default": "mdi:alarm-snooze"
},
"sunset_duration": {
"default": "mdi:clock-end"
},
"sunset_level": {
"default": "mdi:brightness-5"
},
"sunset_volume": {
"default": "mdi:volume-high"
}
},
"select": {
"days": {
"default": "mdi:calendar-range"
},
"sunset_sound": {
"default": "mdi:playlist-music"
},
"sunset_curve": {
"default": "mdi:weather-sunset"
}
},
"sensor": {
"alarm_status": {
"default": "mdi:alarm-off",
"state": {
"off": "mdi:alarm-off",
"on": "mdi:alarm",
"snooze": "mdi:alarm-snooze",
"wake-up": "mdi:weather-sunset-up",
"sunset": "mdi:weather-sunset-down"
}
}
},
"switch": {
"alarm": {
"default": "mdi:alarm",
"state": {
"on": "mdi:alarm-check",
"off": "mdi:alarm-off"
},
"state_attributes": {
"hour": {
"default": "mdi:alpha-d"
},
"minute": {
"default": "mdi:alpha-m"
},
"day": {
"default": "mdi:calendar-range"
},
"powerwake": {
"default": "mdi:alarm",
"state": {
"on": "mdi:alarm-light",
"off": "mdi:alarm-light-off"
}
},
"powerwake_delta": {
"default": "mdi:clock-start"
}
}
},
"powerwake": {
"default": "mdi:alarm",
"state": {
"on": "mdi:alarm-light",
"off": "mdi:alarm-light-off"
},
"state_attributes": {
"powerwake_delta": {
"default": "mdi:clock-start"
}
}
},
"sunset": {
"default": "mdi:weather-sunset",
"state_attributes": {
"duration": {
"default": "mdi:clock-end"
},
"curve": {
"default": "mdi:weather-sunset"
},
"level": {
"default": "mdi:brightness-5"
},
"sound": {
"default": "mdi:playlist-music"
},
"volume": {
"default": "mdi:volume-high"
}
}
}
},
"text":{
"days_str": {
"default": "mdi:calendar-range"
}
},
"time":{
"time": {
"default": "mdi:clock-digital"
}
}
}
}
4 changes: 2 additions & 2 deletions custom_components/somneo/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"somneo"
],
"requirements": [
"pysomneo==4.0.2"
"pysomneo==4.1.0"
],
"ssdp": [
{
"nt": "urn:philips-com:device:DiProduct:1",
"modelName": "Wake-up Light"
}
],
"version": "2024.2.0"
"version": "2024.2.1"
}
10 changes: 3 additions & 7 deletions custom_components/somneo/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import DOMAIN, PW_ICON, SNOOZE_ICON, SUNSET_ICON
from .const import DOMAIN
from .entity import SomneoEntity

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -53,15 +53,15 @@ class SomneoPowerWake(SomneoEntity, NumberEntity):
_attr_has_entity_name = True
_attr_native_min_value = 0
_attr_native_max_value = 59
_attr_icon = PW_ICON
_attr_translation_key = "powerwake_delta"

def __init__(self, coordinator, unique_id, name, dev_info, alarm):
"""Initialize number entities."""
super().__init__(
coordinator, unique_id, name, dev_info, "alarm" + str(alarm) + "_powerwake_delta"
)

self._attr_translation_key = "alarm" + str(alarm) + "_powerwake_delta"
self._attr_translation_placeholders = {"number": str(alarm)}

self._alarm = alarm

Expand All @@ -86,7 +86,6 @@ class SomneoSnooze(SomneoEntity, NumberEntity):
_attr_native_min_value = 1
_attr_native_max_value = 20
_attr_native_step = 1
_attr_icon = SNOOZE_ICON
_attr_has_entity_name = True

@callback
Expand All @@ -108,7 +107,6 @@ class SomneoSunsetDuration(SomneoEntity, NumberEntity):
_attr_native_min_value = 5
_attr_native_max_value = 60
_attr_native_step = 5
_attr_icon = SUNSET_ICON
_attr_has_entity_name = True

@callback
Expand All @@ -130,7 +128,6 @@ class SomneoSunsetLevel(SomneoEntity, NumberEntity):
_attr_native_min_value = 0
_attr_native_max_value = 25
_attr_native_step = 1
_attr_icon = SUNSET_ICON
_attr_has_entity_name = True

@callback
Expand All @@ -152,7 +149,6 @@ class SomneoSunsetVolume(SomneoEntity, NumberEntity):
_attr_native_min_value = 1
_attr_native_max_value = 25
_attr_native_step = 1
_attr_icon = SUNSET_ICON
_attr_has_entity_name = True

@callback
Expand Down
18 changes: 9 additions & 9 deletions custom_components/somneo/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
from homeassistant.const import CONF_NAME
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from pysomneo import SOUND_DUSK
from pysomneo import FM_PRESETS

from .const import (
CUSTOM,
DOMAIN,
EVERYDAY,
SUNSET_ICON,
TOMORROW,
WEEKEND,
WORKDAYS,
WORKDAYS_ICON,
)
from .entity import SomneoEntity

Expand Down Expand Up @@ -54,17 +52,17 @@ class SomneoDays(SomneoEntity, SelectEntity):
"""Representation of a alarm days."""

_attr_should_poll = True
_attr_icon = WORKDAYS_ICON
_attr_assumed_state = False
_attr_available = True
_attr_options = [WORKDAYS, WEEKEND, TOMORROW, EVERYDAY, CUSTOM]
_attr_current_option = WORKDAYS
_attr_translation_key = "days"

def __init__(self, coordinator, unique_id, name, dev_info, alarm):
"""Initialize number entities."""
super().__init__(coordinator, unique_id, name, dev_info, "alarm" + str(alarm))

self._attr_translation_key = "alarm" + str(alarm) + "_days"
self._attr_translation_placeholders = {"number": str(alarm)}
self._alarm = alarm

@callback
Expand All @@ -84,13 +82,16 @@ class SomneoSunsetSound(SomneoEntity, SelectEntity):
"""Representation of a sunset sound source."""

_attr_should_poll = True
_attr_icon = SUNSET_ICON
_attr_translation_key = "sunset_sound"
_attr_assumed_state = False
_attr_available = True
_attr_options = [item.replace(" ", "_") for item in SOUND_DUSK.keys()]
_attr_current_option = "soft_rain"

@property
def options(self) -> list:
"""Return a set of selectable options."""
return [item.replace(" ", "_") for item in self.coordinator.somneo.dusk_sound_themes] + [item.replace(" ", "_") for item in FM_PRESETS]

@callback
def _handle_coordinator_update(self) -> None:
_LOGGER.debug(self.coordinator.data["sunset"]["sound"])
Expand All @@ -108,7 +109,6 @@ class SomneoSunsetCurve(SomneoEntity, SelectEntity):
"""Representation of a sunset curve."""

_attr_should_poll = True
_attr_icon = SUNSET_ICON
_attr_translation_key = "sunset_curve"
_attr_assumed_state = False
_attr_available = True
Expand All @@ -117,7 +117,7 @@ class SomneoSunsetCurve(SomneoEntity, SelectEntity):
@property
def options(self) -> list:
"""Return a set of selectable options."""
return [item.replace(" ", "_") for item in self.coordinator.somneo.light_curves]
return [item.replace(" ", "_") for item in self.coordinator.somneo.dusk_light_themes]

@callback
def _handle_coordinator_update(self) -> None:
Expand Down
14 changes: 0 additions & 14 deletions custom_components/somneo/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,3 @@ class SomneoAlarmStatus(SomneoEntity, SensorEntity):
def _handle_coordinator_update(self) -> None:
self._attr_native_value = self.coordinator.data["somneo_status"]
self.async_write_ha_state()

@property
def icon(self):
"""Icon."""
if self._attr_native_value == "off":
return "mdi:alarm-off"
if self._attr_native_value == "on":
return "mdi:alarm"
if self._attr_native_value == "snooze":
return "mdi:alarm-snooze"
if self._attr_native_value == "wake-up":
return "mdi:weather-sunset-up"
if self._attr_native_value == "sunset":
return "mdi:weather-sunset-down"
Loading

0 comments on commit 78743cd

Please sign in to comment.