Add alexa remote support (#120878)

* Updated the AlexaModeController to support the remote domain. Also added an alexa entitiy adapter for the remote domain.

* Fixed copy paste mistake.

* Fixed power state for remove domain.

* Updated the CapabilityResource to support labels with the corresponding locale. This local is read from the users config.

* Add the alexa display category 'REMOTE' and use it for the remote capability.

* Revert "Updated the CapabilityResource to support labels with the corresponding locale. This local is read from the users config."

This reverts commit fbdf37904a.

* Fix error when the remote does not have an activtiy list.

* Add tests for the state report of a remote entity.

* Add a test for alexas set mode directive for a remote entitiy.

* Add a test for alexas TurnOn and TurnOff directives for a remote entity.

* Apply suggestions from code review

Fix copy paste mistakes.

Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>

* Improve attribute name as suggested.

Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>

* Add test case with zero and one activity.

* Add a comment why we use the mode controller instead of the input controller.

* Add test to check of the discovery returns all required interfaces for a remote entitiy.

* Tweak comment

* Add line breaks to fix max allowed chars per line.

---------

Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
This commit is contained in:
CrazyMan2000
2024-07-09 18:03:47 +02:00
committed by GitHub
parent 154da1b18b
commit e44f00cf7c
5 changed files with 254 additions and 1 deletions

View File

@@ -27,6 +27,7 @@ from homeassistant.components import (
lock,
media_player,
number,
remote,
scene,
script,
sensor,
@@ -196,6 +197,10 @@ class DisplayCategory:
# Indicates a device that prints.
PRINTER = "PRINTER"
# Indicates a decive that support stateless events,
# such as remote switches and smart buttons.
REMOTE = "REMOTE"
# Indicates a network router.
ROUTER = "ROUTER"
@@ -645,6 +650,24 @@ class FanCapabilities(AlexaEntity):
yield Alexa(self.entity)
@ENTITY_ADAPTERS.register(remote.DOMAIN)
class RemoteCapabilities(AlexaEntity):
"""Class to represent Remote capabilities."""
def default_display_categories(self) -> list[str]:
"""Return the display categories for this entity."""
return [DisplayCategory.REMOTE]
def interfaces(self) -> Generator[AlexaCapability]:
"""Yield the supported interfaces."""
yield AlexaPowerController(self.entity)
yield AlexaModeController(
self.entity, instance=f"{remote.DOMAIN}.{remote.ATTR_ACTIVITY}"
)
yield AlexaEndpointHealth(self.hass, self.entity)
yield Alexa(self.entity)
@ENTITY_ADAPTERS.register(humidifier.DOMAIN)
class HumidifierCapabilities(AlexaEntity):
"""Class to represent Humidifier capabilities."""