generated from ludeeus/integration_blueprint
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to control USB Recorder (#26)
Add two new entites - USB Filename (sensor) - USB tape stats (select) Some minor other cleanup
- Loading branch information
Showing
8 changed files
with
101 additions
and
13 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
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
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,56 @@ | ||
"""Select entity platform for behringer_mixer.""" | ||
from __future__ import annotations | ||
|
||
from homeassistant.components.select import SelectEntity, SelectEntityDescription | ||
|
||
from .const import DOMAIN | ||
from .entity import BehringerMixerEntity | ||
|
||
|
||
async def async_setup_entry(hass, entry, async_add_devices): | ||
"""Set up the sensor platform.""" | ||
coordinator = hass.data[DOMAIN][entry.entry_id] | ||
devices_list = build_entities(coordinator) | ||
async_add_devices(devices_list) | ||
|
||
|
||
def build_entities(coordinator): | ||
"""Build up the entities.""" | ||
entities = [] | ||
for entity in coordinator.entity_catalog.get("SELECT"): | ||
entities.append( | ||
BehringerMixerUSBState( | ||
coordinator=coordinator, | ||
entity_description=SelectEntityDescription( | ||
key=entity.get("key"), | ||
name=entity.get("default_name"), | ||
), | ||
entity_setup=entity, | ||
) | ||
) | ||
return entities | ||
|
||
|
||
class BehringerMixerUSBState(BehringerMixerEntity, SelectEntity): | ||
"""Behringer_mixer select class.""" | ||
|
||
_attr_icon = "mdi:play-pause" | ||
_attr_options = [ | ||
"STOP", | ||
"PAUSE", | ||
"PLAY", | ||
"PAUSE_RECORD", | ||
"RECORD", | ||
"FAST_FORWARD", | ||
"REWIND", | ||
] | ||
|
||
async def async_select_option(self, option: str) -> None: | ||
"""Change the selected option.""" | ||
await self.coordinator.client.async_set_value(self.base_address, option) | ||
return True | ||
|
||
@property | ||
def current_option(self) -> str | None: | ||
"""Return the current option.""" | ||
return self.coordinator.data[self.base_address] |