Skip to content
Snippets Groups Projects
Unverified Commit 0eb409cf authored by Maikel Punie's avatar Maikel Punie Committed by GitHub
Browse files

Add support for select entities in velbus (#87568)

* Add support for select entities in velbus

* Implement comments

* EntityCategory is now in homeassistant.const

* more comments
parent 7b18df32
No related branches found
No related tags found
No related merge requests found
......@@ -1368,6 +1368,7 @@ omit =
homeassistant/components/velbus/entity.py
homeassistant/components/velbus/light.py
homeassistant/components/velbus/sensor.py
homeassistant/components/velbus/select.py
homeassistant/components/velbus/switch.py
homeassistant/components/velux/__init__.py
homeassistant/components/velux/cover.py
......
......@@ -34,6 +34,7 @@ PLATFORMS = [
Platform.CLIMATE,
Platform.COVER,
Platform.LIGHT,
Platform.SELECT,
Platform.SENSOR,
Platform.SWITCH,
]
......
"""Support for Velbus select."""
from velbusaio.channels import SelectedProgram
from homeassistant.components.select import SelectEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import EntityCategory
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN
from .entity import VelbusEntity
async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up Velbus select based on config_entry."""
await hass.data[DOMAIN][entry.entry_id]["tsk"]
cntrl = hass.data[DOMAIN][entry.entry_id]["cntrl"]
async_add_entities(VelbusSelect(channel) for channel in cntrl.get_all("select"))
class VelbusSelect(VelbusEntity, SelectEntity):
"""Representation of a select option for velbus."""
_channel: SelectedProgram
_attr_entity_category = EntityCategory.CONFIG
def __init__(
self,
channel: SelectedProgram,
) -> None:
"""Initialize a select Velbus entity."""
super().__init__(channel)
self._attr_options = self._channel.get_options()
self._attr_unique_id = f"{self._attr_unique_id}-program_select"
async def async_select_option(self, option: str) -> None:
"""Update the program on the module."""
await self._channel.set_selected_program(option)
@property
def current_option(self) -> str:
"""Return the selected option."""
return self._channel.get_selected_program()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment