Skip to content

Commit

Permalink
Merge pull request #15 from peteS-UK/develop
Browse files Browse the repository at this point in the history
STR-DN1060 Support and other fixes
  • Loading branch information
peteS-UK authored Jan 2, 2025
2 parents 82c62ad + 310cb94 commit 7a7507f
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 135 deletions.
3 changes: 1 addition & 2 deletions custom_components/sonyavr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,13 @@ def _update_max_volume(sonyavr, value):
async def options_update_listener(
hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry
):

_update_max_volume(
hass.data[DOMAIN][config_entry.entry_id]["sonyavr"],
config_entry.options[CONF_MAX_VOLUME],
)

"""Handle options update."""
await hass.config_entries.async_reload(config_entry.entry_id)
# await hass.config_entries.async_reload(config_entry.entry_id)


async def async_unload_entry(
Expand Down
8 changes: 6 additions & 2 deletions custom_components/sonyavr/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
import homeassistant.helpers.config_validation as cv
import voluptuous as vol
from homeassistant import config_entries, core, exceptions
from homeassistant.const import CONF_HOST, CONF_MODEL, CONF_NAME, CONF_PORT
from homeassistant.const import (
CONF_HOST,
CONF_MODEL,
CONF_NAME,
CONF_PORT,
)
from homeassistant.core import callback


from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/sonyavr/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"iot_class": "local_push",
"issue_tracker": "https://github.com/peteS-UK/sonyavr/issues",
"requirements": [],
"version": "1.3.0"
"version": "1.5.0"
}
20 changes: 12 additions & 8 deletions custom_components/sonyavr/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
entity_platform,
)
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.start import async_at_start
from homeassistant.helpers.start import async_at_started

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -95,25 +95,29 @@ async def _async_startup(self, loop):
)
await self._device.command_service.async_connect()

# Turn on and off to force the feedback
await self._device.async_turn_on()
await asyncio.sleep(20)
await self._device.async_update_status()
await asyncio.sleep(10)
await self._device.async_turn_off()
async def _inititalise():
# Turn on and off to force the feedback
await self._device.async_turn_on()
await asyncio.sleep(20)
await self._device.async_update_status()
await asyncio.sleep(10)
await self._device.async_turn_off()

self._hass.async_create_task(_inititalise())

async def async_added_to_hass(self):
"""Subscribe to device events."""
self._device.set_update_cb(self.async_update_callback)

async_at_start(self._hass, self._async_startup)
async_at_started(self._hass, self._async_startup)

# self._config_entry.async_on_unload(async_at_start(self._hass, self._async_startup))

# self._notifier_task = asyncio.create_task(self._device.run_notifier())

def async_update_callback(self, reason=False):
"""Update the device's state."""
_LOGGER.debug("Updating Media Player state")
self.async_schedule_update_ha_state()

async def async_will_remove_from_hass(self) -> None:
Expand Down
5 changes: 4 additions & 1 deletion custom_components/sonyavr/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ def entity_id(self, entity_id):

@property
def device_class(self):
return SensorDeviceClass.SOUND_PRESSURE
if self._device.state_service.volume_model == 3:
return None
else:
return SensorDeviceClass.SOUND_PRESSURE

@property
def native_unit_of_measurement(self):
Expand Down
Loading

0 comments on commit 7a7507f

Please sign in to comment.