mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Remove Rituals room size number entity (#52200)
This commit is contained in:
parent
253310aaa4
commit
a9bd7da79d
@ -11,7 +11,7 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import RitualsDataUpdateCoordinator
|
from . import RitualsDataUpdateCoordinator
|
||||||
from .const import ATTRIBUTES, COORDINATORS, DEVICES, DOMAIN, ROOM, SPEED
|
from .const import ATTRIBUTES, COORDINATORS, DEVICES, DOMAIN, SPEED
|
||||||
from .entity import DiffuserEntity
|
from .entity import DiffuserEntity
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -22,7 +22,6 @@ MIN_ROOM_SIZE = 1
|
|||||||
MAX_ROOM_SIZE = 4
|
MAX_ROOM_SIZE = 4
|
||||||
|
|
||||||
PERFUME_AMOUNT_SUFFIX = " Perfume Amount"
|
PERFUME_AMOUNT_SUFFIX = " Perfume Amount"
|
||||||
ROOM_SIZE_SUFFIX = " Room Size"
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@ -37,7 +36,6 @@ async def async_setup_entry(
|
|||||||
for hublot, diffuser in diffusers.items():
|
for hublot, diffuser in diffusers.items():
|
||||||
coordinator = coordinators[hublot]
|
coordinator = coordinators[hublot]
|
||||||
entities.append(DiffuserPerfumeAmount(diffuser, coordinator))
|
entities.append(DiffuserPerfumeAmount(diffuser, coordinator))
|
||||||
entities.append(DiffuserRoomSize(diffuser, coordinator))
|
|
||||||
|
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
@ -82,45 +80,3 @@ class DiffuserPerfumeAmount(NumberEntity, DiffuserEntity):
|
|||||||
MIN_PERFUME_AMOUNT,
|
MIN_PERFUME_AMOUNT,
|
||||||
MAX_PERFUME_AMOUNT,
|
MAX_PERFUME_AMOUNT,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class DiffuserRoomSize(NumberEntity, DiffuserEntity):
|
|
||||||
"""Representation of a diffuser room size number."""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self, diffuser: Diffuser, coordinator: RitualsDataUpdateCoordinator
|
|
||||||
) -> None:
|
|
||||||
"""Initialize the diffuser room size number."""
|
|
||||||
super().__init__(diffuser, coordinator, ROOM_SIZE_SUFFIX)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def icon(self) -> str:
|
|
||||||
"""Return the icon of the room size entity."""
|
|
||||||
return "mdi:ruler-square"
|
|
||||||
|
|
||||||
@property
|
|
||||||
def value(self) -> int:
|
|
||||||
"""Return the current room size."""
|
|
||||||
return self._diffuser.hub_data[ATTRIBUTES][ROOM]
|
|
||||||
|
|
||||||
@property
|
|
||||||
def min_value(self) -> int:
|
|
||||||
"""Return the minimum room size."""
|
|
||||||
return MIN_ROOM_SIZE
|
|
||||||
|
|
||||||
@property
|
|
||||||
def max_value(self) -> int:
|
|
||||||
"""Return the maximum room size."""
|
|
||||||
return MAX_ROOM_SIZE
|
|
||||||
|
|
||||||
async def async_set_value(self, value: float) -> None:
|
|
||||||
"""Set the room size."""
|
|
||||||
if value.is_integer() and MIN_ROOM_SIZE <= value <= MAX_ROOM_SIZE:
|
|
||||||
await self._diffuser.set_room_size(int(value))
|
|
||||||
else:
|
|
||||||
_LOGGER.warning(
|
|
||||||
"Can't set the room size to %s. Room size must be an integer between %s and %s, inclusive",
|
|
||||||
value,
|
|
||||||
MIN_ROOM_SIZE,
|
|
||||||
MAX_ROOM_SIZE,
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user