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
8 changes: 3 additions & 5 deletions custom_components/extron/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,12 @@ async def async_step_user(self, user_input: dict[str, Any] | None = None):

@staticmethod
def async_get_options_flow(config_entry: ConfigEntry) -> OptionsFlow:
"""Create the options flow"""
return ExtronOptionsFlowHandler(config_entry)
return ExtronOptionsFlowHandler()


class ExtronOptionsFlowHandler(OptionsFlow):
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize options flow."""
self.config_entry = config_entry
def __init__(self) -> None:
pass

async def async_step_init(self, user_input: dict[str, Any] | None = None):
"""Manage optional settings for the entry."""
Expand Down
30 changes: 19 additions & 11 deletions custom_components/extron/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ def unique_id(self) -> str | None:
def state(self):
return self._state

@property
def available(self) -> bool:
return self._device.is_connected()

@property
def device_info(self) -> DeviceInfo:
return self._device_information.device_info
Expand Down Expand Up @@ -89,10 +85,15 @@ def get_device_type(self):
return DeviceType.SURROUND_SOUND_PROCESSOR

async def async_update(self):
self._source = self._source_bidict.get(await self._ssp.view_input())
self._muted = await self._ssp.is_muted()
volume = await self._ssp.get_volume_level()
self._volume = volume / 100
try:
self._source = self._source_bidict.get(await self._ssp.view_input())
self._muted = await self._ssp.is_muted()
volume = await self._ssp.get_volume_level()
self._volume = volume / 100
except Exception:
self._attr_available = False
else:
self._attr_available = True

@property
def volume_level(self):
Expand Down Expand Up @@ -127,10 +128,12 @@ async def async_set_volume_level(self, volume: float) -> None:
await self._ssp.set_volume_level(int(volume * 100))

async def async_volume_up(self) -> None:
await self._ssp.increment_volume()
if int(self._volume * 100) < 100:
await self._ssp.increment_volume()

async def async_volume_down(self) -> None:
await self._ssp.decrement_volume()
if int(self._volume * 100) > 0:
await self._ssp.decrement_volume()


class ExtronHDMISwitcher(AbstractExtronMediaPlayerEntity):
Expand All @@ -150,7 +153,12 @@ def get_device_type(self):
return DeviceType.HDMI_SWITCHER

async def async_update(self):
self._source = self._source_bidict.get(await self._hdmi_switcher.view_input())
try:
self._source = self._source_bidict.get(await self._hdmi_switcher.view_input())
except Exception:
self._attr_available = False
else:
self._attr_available = True

@property
def source(self):
Expand Down
7 changes: 6 additions & 1 deletion custom_components/extron/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,9 @@ def native_value(self) -> StateType | date | datetime | Decimal:
return self._native_value

async def async_update(self):
self._native_value = await self._ssp.get_temperature()
try:
self._native_value = await self._ssp.get_temperature()
except Exception:
self._attr_available = False
else:
self._attr_available = True