-
-
Notifications
You must be signed in to change notification settings - Fork 37.5k
Add snapcast latency attribute and service #34126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MartinHjelmare
merged 11 commits into
home-assistant:dev
from
BarrettLowe:SnapcastLatency
Apr 14, 2020
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
49ecdae
Implemented snapcast latency attributes
BarrettLowe f81bfc1
Code review changes and Snapcast maintenance
BarrettLowe 35abd34
Cleanup tasks
BarrettLowe c234c56
FIx linting errors
BarrettLowe cde19dc
Sort imports
BarrettLowe 027586c
Update with requested change
BarrettLowe b5c737f
Add guards for bad service calls
BarrettLowe 47d85f1
Add back in platform schema
BarrettLowe 6a7bed7
Add check for unjoin service call
BarrettLowe 68a7d90
Fix lint/format
BarrettLowe 6f50d59
remove comma inserted by black
BarrettLowe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,50 +1 @@ | ||
| """The snapcast component.""" | ||
|
|
||
| import asyncio | ||
|
|
||
| import voluptuous as vol | ||
|
|
||
| from homeassistant.const import ATTR_ENTITY_ID | ||
| from homeassistant.helpers import config_validation as cv | ||
| from homeassistant.helpers.dispatcher import async_dispatcher_send | ||
|
|
||
| DOMAIN = "snapcast" | ||
|
|
||
| SERVICE_SNAPSHOT = "snapshot" | ||
| SERVICE_RESTORE = "restore" | ||
| SERVICE_JOIN = "join" | ||
| SERVICE_UNJOIN = "unjoin" | ||
|
|
||
| ATTR_MASTER = "master" | ||
|
|
||
| SERVICE_SCHEMA = vol.Schema({vol.Required(ATTR_ENTITY_ID): cv.entity_ids}) | ||
|
|
||
| JOIN_SERVICE_SCHEMA = SERVICE_SCHEMA.extend({vol.Required(ATTR_MASTER): cv.entity_id}) | ||
|
|
||
|
|
||
| async def async_setup(hass, config): | ||
| """Handle service configuration.""" | ||
| service_event = asyncio.Event() | ||
|
|
||
| async def service_handle(service): | ||
| """Dispatch a service call.""" | ||
| service_event.clear() | ||
| async_dispatcher_send( | ||
| hass, DOMAIN, service_event, service.service, service.data | ||
| ) | ||
| await service_event.wait() | ||
|
|
||
| hass.services.async_register( | ||
| DOMAIN, SERVICE_SNAPSHOT, service_handle, schema=SERVICE_SCHEMA | ||
| ) | ||
| hass.services.async_register( | ||
| DOMAIN, SERVICE_RESTORE, service_handle, schema=SERVICE_SCHEMA | ||
| ) | ||
| hass.services.async_register( | ||
| DOMAIN, SERVICE_JOIN, service_handle, schema=JOIN_SERVICE_SCHEMA | ||
| ) | ||
| hass.services.async_register( | ||
| DOMAIN, SERVICE_UNJOIN, service_handle, schema=SERVICE_SCHEMA | ||
| ) | ||
|
|
||
| return True |
This file contains hidden or 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,17 @@ | ||
| """Constants for Snapcast.""" | ||
|
|
||
| DATA_KEY = "snapcast" | ||
|
|
||
| GROUP_PREFIX = "snapcast_group_" | ||
| GROUP_SUFFIX = "Snapcast Group" | ||
| CLIENT_PREFIX = "snapcast_client_" | ||
| CLIENT_SUFFIX = "Snapcast Client" | ||
|
|
||
| SERVICE_SNAPSHOT = "snapshot" | ||
| SERVICE_RESTORE = "restore" | ||
| SERVICE_JOIN = "join" | ||
| SERVICE_UNJOIN = "unjoin" | ||
| SERVICE_SET_LATENCY = "set_latency" | ||
|
|
||
| ATTR_MASTER = "master" | ||
| ATTR_LATENCY = "latency" |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.