1 """Support for Panasonic Blu-ray players."""
3 from __future__
import annotations
5 from datetime
import timedelta
7 from panacotta
import PanasonicBD
8 import voluptuous
as vol
11 PLATFORM_SCHEMA
as MEDIA_PLAYER_PLATFORM_SCHEMA,
13 MediaPlayerEntityFeature,
23 DEFAULT_NAME =
"Panasonic Blu-Ray"
28 PLATFORM_SCHEMA = MEDIA_PLAYER_PLATFORM_SCHEMA.extend(
30 vol.Required(CONF_HOST): cv.string,
31 vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
39 add_entities: AddEntitiesCallback,
40 discovery_info: DiscoveryInfoType |
None =
None,
42 """Set up the Panasonic Blu-ray platform."""
43 conf = discovery_info
if discovery_info
else config
50 """Representation of a Panasonic Blu-ray device."""
52 _attr_icon =
"mdi:disc-player"
53 _attr_supported_features = (
54 MediaPlayerEntityFeature.TURN_ON
55 | MediaPlayerEntityFeature.TURN_OFF
56 | MediaPlayerEntityFeature.PLAY
57 | MediaPlayerEntityFeature.STOP
58 | MediaPlayerEntityFeature.PAUSE
62 """Initialize the Panasonic Blue-ray device."""
70 """Update the internal state by querying the device."""
72 state = self.
_device_device.get_play_status()
74 if state[0] ==
"error":
76 elif state[0]
in [
"off",
"standby"]:
81 elif state[0]
in [
"paused",
"stopped"]:
83 elif state[0] ==
"playing":
84 self.
_attr_state_attr_state = MediaPlayerState.PLAYING
95 """Instruct the device to turn standby.
97 Sending the "POWER" button will turn the device to standby - there
98 is no way to turn it completely off remotely. However this works in
99 our favour as it means the device is still accepting commands and we
100 can thus turn it back on when desired.
103 self.
_device_device.send_key(
"POWER")
108 """Wake the device back up from standby."""
110 self.
_device_device.send_key(
"POWER")
112 self.
_attr_state_attr_state = MediaPlayerState.IDLE
115 """Send play command."""
116 self.
_device_device.send_key(
"PLAYBACK")
119 """Send pause command."""
120 self.
_device_device.send_key(
"PAUSE")
123 """Send stop command."""
124 self.
_device_device.send_key(
"STOP")
None add_entities(AsusWrtRouter router, AddEntitiesCallback async_add_entities, set[str] tracked)