Add action exceptions to Cambridge Audio (#131597)

This commit is contained in:
Noah Husby 2024-11-26 02:56:11 -05:00 committed by GitHub
parent 4702d8ddb0
commit b1a540a772
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -12,7 +12,7 @@ from homeassistant.const import EntityCategory
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .entity import CambridgeAudioEntity
from .entity import CambridgeAudioEntity, command
@dataclass(frozen=True, kw_only=True)
@ -116,6 +116,7 @@ class CambridgeAudioSelect(CambridgeAudioEntity, SelectEntity):
"""Return the state of the select."""
return self.entity_description.value_fn(self.client)
@command
async def async_select_option(self, option: str) -> None:
"""Change the selected option."""
await self.entity_description.set_value_fn(self.client, option)

View File

@ -12,7 +12,7 @@ from homeassistant.const import EntityCategory
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .entity import CambridgeAudioEntity
from .entity import CambridgeAudioEntity, command
@dataclass(frozen=True, kw_only=True)
@ -73,10 +73,12 @@ class CambridgeAudioSwitch(CambridgeAudioEntity, SwitchEntity):
"""Return the state of the switch."""
return self.entity_description.value_fn(self.client)
@command
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the switch on."""
await self.entity_description.set_value_fn(self.client, True)
@command
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the switch off."""
await self.entity_description.set_value_fn(self.client, False)