Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ Not every single feature can be controlled, only the basics:

The communication is done using Python's `asyncio` and requires no external libraries.

## Caveats

* SSP 200 surround sound processors seem to stop responding properly (both to commands and to physical interactions
like button presses) after some time, requiring a reboot

## Development

Developing the integration and testing it locally in Home Assistant are two separate tasks.
Expand Down
6 changes: 4 additions & 2 deletions custom_components/extron/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from homeassistant.helpers.device_registry import DeviceInfo, format_mac
from pyextron import AuthenticationError, ExtronDevice

from custom_components.extron.const import OPTION_INPUT_NAMES
from custom_components.extron.const import EXTRON_DEVICE_TIMEOUT_SECONDS, OPTION_INPUT_NAMES

PLATFORMS: list[Platform] = [Platform.MEDIA_PLAYER, Platform.SENSOR, Platform.BUTTON]
_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -56,7 +56,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Extron from a config entry."""
# Verify we can connect to the device
try:
device = ExtronDevice(entry.data["host"], entry.data["port"], entry.data["password"])
device = ExtronDevice(
entry.data["host"], entry.data["port"], entry.data["password"], timeout=EXTRON_DEVICE_TIMEOUT_SECONDS
)
await device.connect()
await device.disconnect()
except AuthenticationError as e:
Expand Down
17 changes: 15 additions & 2 deletions custom_components/extron/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@
from homeassistant.helpers.selector import selector
from pyextron import AuthenticationError, DeviceType, ExtronDevice

from .const import CONF_DEVICE_TYPE, CONF_HOST, CONF_PASSWORD, CONF_PORT, DOMAIN, OPTION_INPUT_NAMES
from .const import (
CONF_DEVICE_TYPE,
CONF_HOST,
CONF_PASSWORD,
CONF_PORT,
DOMAIN,
EXTRON_DEVICE_TIMEOUT_SECONDS,
OPTION_INPUT_NAMES,
)

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -45,7 +53,12 @@ async def async_step_user(self, user_input: dict[str, Any] | None = None):
if user_input is not None:
try:
# Try to connect to the device
extron_device = ExtronDevice(user_input["host"], user_input["port"], user_input["password"])
extron_device = ExtronDevice(
user_input["host"],
user_input["port"],
user_input["password"],
timeout=EXTRON_DEVICE_TIMEOUT_SECONDS,
)
await extron_device.connect()

# Make a title for the entry
Expand Down
7 changes: 7 additions & 0 deletions custom_components/extron/const.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Constants for the Extron integration."""

from datetime import timedelta

DOMAIN = "extron"

CONF_HOST = "host"
Expand All @@ -8,3 +10,8 @@
CONF_DEVICE_TYPE = "device_type"

OPTION_INPUT_NAMES = "input_names"

EXTRON_DEVICE_TIMEOUT_SECONDS = 10

# Poll entities every 30 seconds
SCAN_INTERVAL = timedelta(minutes=30)
3 changes: 2 additions & 1 deletion custom_components/extron/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,5 @@ def create_source_bidict(self) -> bidict:
return make_source_bidict(num_sources, self._input_names)

async def async_select_source(self, source: str):
await self._hdmi_switcher.select_input(self._source_bidict.inverse.get(source))
async with self._hdmi_switcher._device.connection():
await self._hdmi_switcher.select_input(self._source_bidict.inverse.get(source))