-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add assist satellite entity component (#125351)
* Add assist_satellite * Update homeassistant/components/assist_satellite/manifest.json Co-authored-by: Paulus Schoutsen <[email protected]> * Update homeassistant/components/assist_satellite/manifest.json Co-authored-by: Paulus Schoutsen <[email protected]> * Add platform constant * Update Dockerfile * Apply suggestions from code review Co-authored-by: Martin Hjelmare <[email protected]> * Address comments * Update docstring async_internal_announce * Update CODEOWNERS --------- Co-authored-by: Paulus Schoutsen <[email protected]> Co-authored-by: Martin Hjelmare <[email protected]>
- Loading branch information
1 parent
c3921f2
commit 60b0f0d
Showing
22 changed files
with
1,188 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
"""Base class for assist satellite entities.""" | ||
|
||
import logging | ||
|
||
import voluptuous as vol | ||
|
||
from homeassistant.config_entries import ConfigEntry | ||
from homeassistant.core import HomeAssistant | ||
from homeassistant.helpers import config_validation as cv | ||
from homeassistant.helpers.entity_component import EntityComponent | ||
from homeassistant.helpers.typing import ConfigType | ||
|
||
from .const import DOMAIN, AssistSatelliteEntityFeature | ||
from .entity import AssistSatelliteEntity, AssistSatelliteEntityDescription | ||
from .errors import SatelliteBusyError | ||
from .websocket_api import async_register_websocket_api | ||
|
||
__all__ = [ | ||
"DOMAIN", | ||
"AssistSatelliteEntity", | ||
"AssistSatelliteEntityDescription", | ||
"AssistSatelliteEntityFeature", | ||
"SatelliteBusyError", | ||
] | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE | ||
|
||
|
||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: | ||
component = hass.data[DOMAIN] = EntityComponent[AssistSatelliteEntity]( | ||
_LOGGER, DOMAIN, hass | ||
) | ||
await component.async_setup(config) | ||
|
||
component.async_register_entity_service( | ||
"announce", | ||
vol.All( | ||
cv.make_entity_service_schema( | ||
{ | ||
vol.Optional("message"): str, | ||
vol.Optional("media_id"): str, | ||
} | ||
), | ||
cv.has_at_least_one_key("message", "media_id"), | ||
), | ||
"async_internal_announce", | ||
[AssistSatelliteEntityFeature.ANNOUNCE], | ||
) | ||
async_register_websocket_api(hass) | ||
|
||
return True | ||
|
||
|
||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: | ||
"""Set up a config entry.""" | ||
component: EntityComponent[AssistSatelliteEntity] = hass.data[DOMAIN] | ||
return await component.async_setup_entry(entry) | ||
|
||
|
||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: | ||
"""Unload a config entry.""" | ||
component: EntityComponent[AssistSatelliteEntity] = hass.data[DOMAIN] | ||
return await component.async_unload_entry(entry) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"""Constants for assist satellite.""" | ||
|
||
from enum import IntFlag | ||
|
||
DOMAIN = "assist_satellite" | ||
|
||
|
||
class AssistSatelliteEntityFeature(IntFlag): | ||
"""Supported features of Assist satellite entity.""" | ||
|
||
ANNOUNCE = 1 | ||
"""Device supports remotely triggered announcements.""" |
Oops, something went wrong.