Updated apps
This commit is contained in:
@@ -0,0 +1 @@
|
||||
"""Spook - Your homie."""
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
"""Spook - Your homie."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.input_select import DOMAIN
|
||||
|
||||
from ...select.services.random import SpookService as SelectRandomSpookService
|
||||
|
||||
|
||||
class SpookService(SelectRandomSpookService):
|
||||
"""Input select entity service, select a random option.
|
||||
|
||||
Clone of the select_random service, but for input_select entities.
|
||||
"""
|
||||
|
||||
domain = DOMAIN
|
||||
@@ -0,0 +1,34 @@
|
||||
"""Spook - Your homie."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import random
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from homeassistant.components.input_select import DOMAIN, InputSelect
|
||||
|
||||
from ....services import AbstractSpookEntityComponentService
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from homeassistant.core import ServiceCall
|
||||
|
||||
|
||||
class SpookService(AbstractSpookEntityComponentService[InputSelect]):
|
||||
"""Input select entity service, shuffling the positions.
|
||||
|
||||
These changes are not permanent, and will be lost when input select entities
|
||||
are loaded/changed, or when Home Assistant is restarted.
|
||||
"""
|
||||
|
||||
domain = DOMAIN
|
||||
service = "shuffle"
|
||||
|
||||
async def async_handle_service(
|
||||
self,
|
||||
entity: InputSelect,
|
||||
call: ServiceCall, # noqa: ARG002
|
||||
) -> None:
|
||||
"""Handle the service call."""
|
||||
# pylint: disable-next=protected-access
|
||||
random.shuffle(entity._attr_options) # noqa: SLF001
|
||||
entity.async_write_ha_state()
|
||||
@@ -0,0 +1,33 @@
|
||||
"""Spook - Your homie."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from homeassistant.components.input_select import DOMAIN, InputSelect
|
||||
|
||||
from ....services import AbstractSpookEntityComponentService
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from homeassistant.core import ServiceCall
|
||||
|
||||
|
||||
class SpookService(AbstractSpookEntityComponentService[InputSelect]):
|
||||
"""Input select entity service, sorting the positions.
|
||||
|
||||
These changes are not permanent, and will be lost when input select entities
|
||||
are loaded/changed, or when Home Assistant is restarted.
|
||||
"""
|
||||
|
||||
domain = DOMAIN
|
||||
service = "sort"
|
||||
|
||||
async def async_handle_service(
|
||||
self,
|
||||
entity: InputSelect,
|
||||
call: ServiceCall, # noqa: ARG002
|
||||
) -> None:
|
||||
"""Handle the service call."""
|
||||
# pylint: disable-next=protected-access
|
||||
entity._attr_options.sort() # noqa: SLF001
|
||||
entity.async_write_ha_state()
|
||||
Reference in New Issue
Block a user