ESPHome select for assist pipeline selection (#91526)
* ESPHome: Add assist pipeline select entity * Add translation strings * Tests
This commit is contained in:
parent
ef7e3e27ba
commit
aeb19831d2
7 changed files with 87 additions and 32 deletions
|
@ -3,12 +3,20 @@ from __future__ import annotations
|
|||
|
||||
from aioesphomeapi import SelectInfo, SelectState
|
||||
|
||||
from homeassistant.components.assist_pipeline.select import AssistPipelineSelect
|
||||
from homeassistant.components.select import SelectEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import EsphomeEntity, esphome_state_property, platform_async_setup_entry
|
||||
from . import (
|
||||
EsphomeAssistEntity,
|
||||
EsphomeEntity,
|
||||
esphome_state_property,
|
||||
platform_async_setup_entry,
|
||||
)
|
||||
from .domain_data import DomainData
|
||||
from .entry_data import RuntimeEntryData
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
|
@ -27,6 +35,11 @@ async def async_setup_entry(
|
|||
state_type=SelectState,
|
||||
)
|
||||
|
||||
entry_data = DomainData.get(hass).get_entry_data(entry)
|
||||
assert entry_data.device_info is not None
|
||||
if entry_data.device_info.voice_assistant_version:
|
||||
async_add_entities([EsphomeAssistPipelineSelect(hass, entry_data)])
|
||||
|
||||
|
||||
class EsphomeSelect(EsphomeEntity[SelectInfo, SelectState], SelectEntity):
|
||||
"""A select implementation for esphome."""
|
||||
|
@ -47,3 +60,12 @@ class EsphomeSelect(EsphomeEntity[SelectInfo, SelectState], SelectEntity):
|
|||
async def async_select_option(self, option: str) -> None:
|
||||
"""Change the selected option."""
|
||||
await self._client.select_command(self._static_info.key, option)
|
||||
|
||||
|
||||
class EsphomeAssistPipelineSelect(EsphomeAssistEntity, AssistPipelineSelect):
|
||||
"""Pipeline selector for esphome devices."""
|
||||
|
||||
def __init__(self, hass: HomeAssistant, entry_data: RuntimeEntryData) -> None:
|
||||
"""Initialize a pipeline selector."""
|
||||
EsphomeAssistEntity.__init__(self, entry_data)
|
||||
AssistPipelineSelect.__init__(self, hass, self._device_info.mac_address)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue