Bump panasonic_viera to 0.4.2 (#120692)

* Bump panasonic_viera to 0.4.2

* Bump panasonic_viera to 0.4.2

* Bump panasonic_viera to 0.4.2

* Fix Keys
This commit is contained in:
Joost Lekkerkerker 2024-06-28 11:15:44 +02:00 committed by Franck Nijhof
parent 876fb234ce
commit ca515f740e
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
6 changed files with 17 additions and 17 deletions

View File

@ -196,10 +196,10 @@ class Remote:
self.muted = self._control.get_mute()
self.volume = self._control.get_volume() / 100
async def async_send_key(self, key):
async def async_send_key(self, key: Keys | str) -> None:
"""Send a key to the TV and handle exceptions."""
try:
key = getattr(Keys, key)
key = getattr(Keys, key.upper())
except (AttributeError, TypeError):
key = getattr(key, "value", key)
@ -211,13 +211,13 @@ class Remote:
await self._on_action.async_run(context=context)
await self.async_update()
elif self.state != STATE_ON:
await self.async_send_key(Keys.power)
await self.async_send_key(Keys.POWER)
await self.async_update()
async def async_turn_off(self):
"""Turn off the TV."""
if self.state != STATE_OFF:
await self.async_send_key(Keys.power)
await self.async_send_key(Keys.POWER)
self.state = STATE_OFF
await self.async_update()

View File

@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/panasonic_viera",
"iot_class": "local_polling",
"loggers": ["panasonic_viera"],
"requirements": ["panasonic-viera==0.3.6"]
"requirements": ["panasonic-viera==0.4.2"]
}

View File

@ -126,11 +126,11 @@ class PanasonicVieraTVEntity(MediaPlayerEntity):
async def async_volume_up(self) -> None:
"""Volume up the media player."""
await self._remote.async_send_key(Keys.volume_up)
await self._remote.async_send_key(Keys.VOLUME_UP)
async def async_volume_down(self) -> None:
"""Volume down media player."""
await self._remote.async_send_key(Keys.volume_down)
await self._remote.async_send_key(Keys.VOLUME_DOWN)
async def async_mute_volume(self, mute: bool) -> None:
"""Send mute command."""
@ -143,33 +143,33 @@ class PanasonicVieraTVEntity(MediaPlayerEntity):
async def async_media_play_pause(self) -> None:
"""Simulate play pause media player."""
if self._remote.playing:
await self._remote.async_send_key(Keys.pause)
await self._remote.async_send_key(Keys.PAUSE)
self._remote.playing = False
else:
await self._remote.async_send_key(Keys.play)
await self._remote.async_send_key(Keys.PLAY)
self._remote.playing = True
async def async_media_play(self) -> None:
"""Send play command."""
await self._remote.async_send_key(Keys.play)
await self._remote.async_send_key(Keys.PLAY)
self._remote.playing = True
async def async_media_pause(self) -> None:
"""Send pause command."""
await self._remote.async_send_key(Keys.pause)
await self._remote.async_send_key(Keys.PAUSE)
self._remote.playing = False
async def async_media_stop(self) -> None:
"""Stop playback."""
await self._remote.async_send_key(Keys.stop)
await self._remote.async_send_key(Keys.STOP)
async def async_media_next_track(self) -> None:
"""Send the fast forward command."""
await self._remote.async_send_key(Keys.fast_forward)
await self._remote.async_send_key(Keys.FAST_FORWARD)
async def async_media_previous_track(self) -> None:
"""Send the rewind command."""
await self._remote.async_send_key(Keys.rewind)
await self._remote.async_send_key(Keys.REWIND)
async def async_play_media(
self, media_type: MediaType | str, media_id: str, **kwargs: Any

View File

@ -1528,7 +1528,7 @@ paho-mqtt==1.6.1
panacotta==0.2
# homeassistant.components.panasonic_viera
panasonic-viera==0.3.6
panasonic-viera==0.4.2
# homeassistant.components.dunehd
pdunehd==1.3.2

View File

@ -1228,7 +1228,7 @@ p1monitor==3.0.0
paho-mqtt==1.6.1
# homeassistant.components.panasonic_viera
panasonic-viera==0.3.6
panasonic-viera==0.4.2
# homeassistant.components.dunehd
pdunehd==1.3.2

View File

@ -46,7 +46,7 @@ async def test_onoff(hass: HomeAssistant, mock_remote) -> None:
await hass.services.async_call(REMOTE_DOMAIN, SERVICE_TURN_ON, data)
await hass.async_block_till_done()
power = getattr(Keys.power, "value", Keys.power)
power = getattr(Keys.POWER, "value", Keys.POWER)
assert mock_remote.send_key.call_args_list == [call(power), call(power)]