Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Compatibility for MediaPlayerDeviceClass and Retain DEVICE_CLASS_SPEAKER Fallback #51

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tjamieg
Copy link

@tjamieg tjamieg commented Dec 28, 2024

Description

This pull request adds compatibility for the MediaPlayerDeviceClass introduced in newer versions of Home Assistant. If MediaPlayerDeviceClass is not available (e.g., in older versions of Home Assistant), the integration will fall back to using DEVICE_CLASS_SPEAKER to maintain backward compatibility.

Key Changes

  • Added a conditional check to determine if MediaPlayerDeviceClass is available at runtime.
  • Retained DEVICE_CLASS_SPEAKER as a fallback for older versions of Home Assistant.
  • Preserved all original comments, formatting, and structure for consistency with the repository's existing style.

Why These Changes Are Important

The DEVICE_CLASS_SPEAKER constant is deprecated and will be removed in Core 2025.10. Without this update, users may encounter deprecation warnings or errors in future releases.

Testing Notes

  • Tested on Home Assistant Core 2024.12.5.
  • Confirmed that MediaPlayerDeviceClass is used if available.
  • Verified that the integration defaults to DEVICE_CLASS_SPEAKER if MediaPlayerDeviceClass is not present.
  • Observed no errors or warnings during testing.

Impact

  • Fully backward-compatible.
  • Introduces no breaking changes.

Introduced a check for the presence of MediaPlayerDeviceClass to ensure compatibility across different Home Assistant versions. If MediaPlayerDeviceClass is unavailable, the integration defaults to DEVICE_CLASS_SPEAKER for backward compatibility. This change ensures future-proofing against deprecated constants and resolves warnings in Home Assistant logs.
Copy link

vercel bot commented Dec 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ha-samsung-soundbar-kidd ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 28, 2024 11:01pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant