I HAVE IT WORKING for what I need! I was wanting a way to use the CD Player (yes I know obsolete technology for some, but I have hundreds of CDs, and the quality is much better than MP3s, so I still enjoy listening to them.) In any case here are the steps I went thru. They maybe advanced for some. It was a learning experience for me, but just make sure you have a backup and enjoy the playtime!
First enable Remote Connections in your bluray Network Settings?
I have an older DMP-BDT220 (which is supported), but I was beating my head against the wall until I figured out i had to change the Remote setting. I hope that helps.
Get Panacotta on a linux machine https://pypi.org/project/panacotta/
pip install panacotta
This will allow you to test from a linux box running python3 to see what your bluray supports.
This is a python script (panacotta_test.py) I wrote to test the functionality of my player:
#NOTE: be sure to put your device IP ADDRESS in at line 4
#!/usr/bin/python3
import panacotta
bluray = panacotta.PanasonicBD('192.168.0.14') # Change to your Device IP Address
KEYS = """
['POWER', 'OP_CL',
'PLAYBACK', 'PAUSE', 'STOP', 'SKIPFWD', 'SKIPREV', 'REV',
'D0', 'D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'D12',
'SHARP', # '#'
'CLEAR', # '*' / CANCEL
'UP', 'DOWN', 'LEFT', 'RIGHT', 'SELECT', 'RETURN', 'EXIT',
'MLTNAVI', # HOME
'DSPSEL', # STATUS
'TITLE', 'MENU', 'PUPMENU',
'SHFWD1', 'SHFWD2', 'SHFWD3', 'SHFWD4', 'SHFWD5',
'SHREV1', 'SHREV2', 'SHREV3', 'SHREV4', 'SHREV5',
'JLEFT', 'JRIGHT',
'RED', 'BLUE', 'GREEN', 'YELLOW',
'NETFLIX', 'SKYPE', 'V_CAST', '3D', 'NETWORK', 'AUDIOSEL',
'KEYS', 'CUE', 'CHROMA',
'MNBACK', 'MNSKIP', '2NDARY', 'PICTMD', 'DETAIL', 'RESOLUTN',
# Playback view?
'OSDONOFF', 'P_IN_P',
]
'Q' to quit!
"""
while True:
print("Device is currently %s" % bluray.get_play_status()[0])
print(f"Available KEYS = {KEYS}")
inp = input("Enter KEY :").upper()
if inp:
inp = inp
if inp == "Q":
break
else:
print(f"executing bluray.send_key('{inp}')...")
print(bluray.send_key(inp))
Once you confirm your panasonic device supports PLAYBACK, PAUSE, OP_CL, SKIPREV, and SKIPFWD…
If you have not done so already, you need to have the panasonic_bluray integration manually installed: https://www.home-assistant.io/integrations/panasonic_bluray
Then SSH or Terminal into your HA instance…
docker exec -it homeassistant bash
cd /usr/src/homeassistant/homeassistant/components/panasonic_bluray/
cp media_player.py media_player.bu
vi media_player.py
change the media_player.py code to the following:
"""Support for Panasonic Blu-ray players."""
from __future__ import annotations
from datetime import timedelta
from panacotta import PanasonicBD
import voluptuous as vol
from homeassistant.components.media_player import (
PLATFORM_SCHEMA,
MediaPlayerEntity,
MediaPlayerEntityFeature,
MediaPlayerState,
)
from homeassistant.const import CONF_HOST, CONF_NAME
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from homeassistant.util.dt import utcnow
DEFAULT_NAME = "Panasonic Blu-Ray"
SCAN_INTERVAL = timedelta(seconds=30)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
}
)
def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Panasonic Blu-ray platform."""
conf = discovery_info if discovery_info else config
# Register configured device with Home Assistant.
add_entities([PanasonicBluRay(conf[CONF_HOST], conf[CONF_NAME])])
class PanasonicBluRay(MediaPlayerEntity):
"""Representation of a Panasonic Blu-ray device."""
_attr_icon = "mdi:disc-player"
_attr_supported_features = (
MediaPlayerEntityFeature.TURN_ON
| MediaPlayerEntityFeature.TURN_OFF
| MediaPlayerEntityFeature.PLAY
| MediaPlayerEntityFeature.STOP
| MediaPlayerEntityFeature.PAUSE
| MediaPlayerEntityFeature.PREVIOUS_TRACK
| MediaPlayerEntityFeature.NEXT_TRACK
)
def __init__(self, ip, name):
"""Initialize the Panasonic Blue-ray device."""
self._device = PanasonicBD(ip)
self._attr_name = name
self._attr_state = MediaPlayerState.OFF
self._attr_media_position = 0
self._attr_media_duration = 0
def update(self) -> None:
"""Update the internal state by querying the device."""
# This can take 5+ seconds to complete
state = self._device.get_play_status()
if state[0] == "error":
self._attr_state = None
elif state[0] in ["off", "standby"]:
# We map both of these to off. If it's really off we can't
# turn it on, but from standby we can go to idle by pressing
# POWER.
self._attr_state = MediaPlayerState.OFF
elif state[0] in ["paused", "stopped"]:
self._attr_state = MediaPlayerState.IDLE
elif state[0] == "playing":
self._attr_state = MediaPlayerState.PLAYING
# Update our current media position + length
if state[1] >= 0:
self._attr_media_position = state[1]
else:
self._attr_media_position = 0
self._attr_media_position_updated_at = utcnow()
self._attr_media_duration = state[2]
def turn_off(self) -> None:
"""Instruct the device to turn standby.
Sending the "POWER" button will turn the device to standby - there
is no way to turn it completely off remotely. However this works in
our favour as it means the device is still accepting commands and we
can thus turn it back on when desired.
"""
if self.state != MediaPlayerState.OFF:
self._device.send_key("POWER")
self._attr_state = MediaPlayerState.OFF
def turn_on(self) -> None:
"""Wake the device back up from standby."""
if self.state == MediaPlayerState.OFF:
self._device.send_key("POWER")
self._attr_state = MediaPlayerState.IDLE
def media_play(self) -> None:
"""Send play command."""
self._device.send_key("PLAYBACK")
def media_pause(self) -> None:
"""Send pause command."""
self._device.send_key("PAUSE")
def media_stop(self) -> None:
"""Send stop command."""
self._device.send_key("OP_CL")
def media_previous_track(self) -> None:
"""Send prev command."""
self._device.send_key("SKIPPREV")
def media_next_track(self) -> None:
"""Send next command."""
self._device.send_key("SKIPFWD")
REBOOT HA (Restarting just the YAML will not work.)
NOTE: the STOP service will now eject the CD. Use Pause/Play instead of stop.
I just have a really basic CD tab using the new sections (drag-n-drop) UI with mushroom cards (HACS) - my panasonic device is ‘pan’ so you will need to change all the ‘media_player.pan’ items to your entity:
type: sections
sections:
- type: grid
cards:
- type: custom:mushroom-media-player-card
entity: media_player.pan
media_controls:
- on_off
- previous
- play_pause_stop
- next
- repeat
- shuffle
use_media_info: true
double_tap_action:
action: more-info
name: Pan
collapsible_controls: false
secondary_info: state
fill_container: false
- type: custom:mushroom-template-card
primary: Eject
icon: mdi:eject
tap_action:
action: call-service
service: media_player.media_stop
target:
entity_id: media_player.pan
icon_color: red
- type: custom:mushroom-template-card
primary: Play/Pause
icon: mdi:play-pause
tap_action:
action: call-service
service: media_player.media_play_pause
target:
entity_id: media_player.pan
icon_color: green
- type: custom:mushroom-template-card
primary: Prev
icon: mdi:skip-previous
tap_action:
action: call-service
service: media_player.media_previous_track
target:
entity_id:
- media_player.pan
icon_color: cyan
- type: custom:mushroom-template-card
primary: Next
icon: mdi:skip-next
tap_action:
action: call-service
service: media_player.media_next_track
target:
entity_id:
- media_player.pan
icon_color: cyan
title: Panasonic
cards: []
max_columns: 4
title: CD
I hope this helps others wanting to start to learn and play with media_player and their panasonic bluray. ENJOY!