Skip to content

Commit

Permalink
Add action exceptions to Cambridge Audio (#131597)
Browse files Browse the repository at this point in the history
  • Loading branch information
noahhusby authored Nov 26, 2024
1 parent 4702d8d commit b1a540a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion homeassistant/components/cambridge_audio/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
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)
Expand Down Expand Up @@ -116,6 +116,7 @@ def current_option(self) -> str | None:
"""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)
4 changes: 3 additions & 1 deletion homeassistant/components/cambridge_audio/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
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)
Expand Down Expand Up @@ -73,10 +73,12 @@ def is_on(self) -> bool:
"""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)

0 comments on commit b1a540a

Please sign in to comment.