mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Bump pyheos to 0.4.1 (#23360)
* Bump pyheos==0.4.1 * Refresh player after reconnection
This commit is contained in:
parent
6fb5b8467b
commit
e3e7fb5ff6
@ -3,7 +3,7 @@
|
|||||||
"name": "Heos",
|
"name": "Heos",
|
||||||
"documentation": "https://www.home-assistant.io/components/heos",
|
"documentation": "https://www.home-assistant.io/components/heos",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"pyheos==0.4.0"
|
"pyheos==0.4.1"
|
||||||
],
|
],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"codeowners": [
|
"codeowners": [
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
"""Denon HEOS Media Player."""
|
"""Denon HEOS Media Player."""
|
||||||
|
import asyncio
|
||||||
from functools import reduce, wraps
|
from functools import reduce, wraps
|
||||||
import logging
|
import logging
|
||||||
from operator import ior
|
from operator import ior
|
||||||
@ -48,7 +49,7 @@ def log_command_error(command: str):
|
|||||||
from pyheos import CommandError
|
from pyheos import CommandError
|
||||||
try:
|
try:
|
||||||
await func(*args, **kwargs)
|
await func(*args, **kwargs)
|
||||||
except CommandError as ex:
|
except (CommandError, asyncio.TimeoutError, ConnectionError) as ex:
|
||||||
_LOGGER.error("Unable to %s: %s", command, ex)
|
_LOGGER.error("Unable to %s: %s", command, ex)
|
||||||
return wrapper
|
return wrapper
|
||||||
return decorator
|
return decorator
|
||||||
@ -86,6 +87,13 @@ class HeosMediaPlayer(MediaPlayerDevice):
|
|||||||
|
|
||||||
async def _heos_event(self, event):
|
async def _heos_event(self, event):
|
||||||
"""Handle connection event."""
|
"""Handle connection event."""
|
||||||
|
from pyheos import CommandError, const
|
||||||
|
if event == const.EVENT_CONNECTED:
|
||||||
|
try:
|
||||||
|
await self._player.refresh()
|
||||||
|
except (CommandError, asyncio.TimeoutError, ConnectionError) as ex:
|
||||||
|
_LOGGER.error("Unable to refresh player %s: %s",
|
||||||
|
self._player, ex)
|
||||||
await self.async_update_ha_state(True)
|
await self.async_update_ha_state(True)
|
||||||
|
|
||||||
async def _player_update(self, player_id, event):
|
async def _player_update(self, player_id, event):
|
||||||
|
@ -1079,7 +1079,7 @@ pygtt==1.1.2
|
|||||||
pyhaversion==2.2.1
|
pyhaversion==2.2.1
|
||||||
|
|
||||||
# homeassistant.components.heos
|
# homeassistant.components.heos
|
||||||
pyheos==0.4.0
|
pyheos==0.4.1
|
||||||
|
|
||||||
# homeassistant.components.hikvision
|
# homeassistant.components.hikvision
|
||||||
pyhik==0.2.2
|
pyhik==0.2.2
|
||||||
|
@ -223,7 +223,7 @@ pydeconz==54
|
|||||||
pydispatcher==2.0.5
|
pydispatcher==2.0.5
|
||||||
|
|
||||||
# homeassistant.components.heos
|
# homeassistant.components.heos
|
||||||
pyheos==0.4.0
|
pyheos==0.4.1
|
||||||
|
|
||||||
# homeassistant.components.homematic
|
# homeassistant.components.homematic
|
||||||
pyhomematic==0.1.58
|
pyhomematic==0.1.58
|
||||||
|
@ -109,13 +109,40 @@ async def test_updates_start_from_signals(
|
|||||||
state = hass.states.get('media_player.test_player')
|
state = hass.states.get('media_player.test_player')
|
||||||
assert state.state == STATE_UNAVAILABLE
|
assert state.state == STATE_UNAVAILABLE
|
||||||
|
|
||||||
# Test heos events update
|
|
||||||
|
async def test_updates_from_connection_event(
|
||||||
|
hass, config_entry, config, controller, input_sources, caplog):
|
||||||
|
"""Tests player updates from connection event after connection failure."""
|
||||||
|
# Connected
|
||||||
|
await setup_platform(hass, config_entry, config)
|
||||||
|
player = controller.players[1]
|
||||||
player.available = True
|
player.available = True
|
||||||
player.heos.dispatcher.send(
|
player.heos.dispatcher.send(
|
||||||
const.SIGNAL_HEOS_EVENT, const.EVENT_CONNECTED)
|
const.SIGNAL_HEOS_EVENT, const.EVENT_CONNECTED)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
state = hass.states.get('media_player.test_player')
|
state = hass.states.get('media_player.test_player')
|
||||||
assert state.state == STATE_PLAYING
|
assert state.state == STATE_IDLE
|
||||||
|
assert player.refresh.call_count == 1
|
||||||
|
|
||||||
|
# Connected handles refresh failure
|
||||||
|
player.reset_mock()
|
||||||
|
player.refresh.side_effect = CommandError(None, "Failure", 1)
|
||||||
|
player.heos.dispatcher.send(
|
||||||
|
const.SIGNAL_HEOS_EVENT, const.EVENT_CONNECTED)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
state = hass.states.get('media_player.test_player')
|
||||||
|
assert player.refresh.call_count == 1
|
||||||
|
assert "Unable to refresh player" in caplog.text
|
||||||
|
|
||||||
|
# Disconnected
|
||||||
|
player.reset_mock()
|
||||||
|
player.available = False
|
||||||
|
player.heos.dispatcher.send(
|
||||||
|
const.SIGNAL_HEOS_EVENT, const.EVENT_DISCONNECTED)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
state = hass.states.get('media_player.test_player')
|
||||||
|
assert state.state == STATE_UNAVAILABLE
|
||||||
|
assert player.refresh.call_count == 0
|
||||||
|
|
||||||
|
|
||||||
async def test_updates_from_sources_updated(
|
async def test_updates_from_sources_updated(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user