From 735fd536446e571fac893e54af9f8c11ceb1c6ed Mon Sep 17 00:00:00 2001 From: samuelspagl Date: Thu, 8 Feb 2024 17:48:58 +0100 Subject: [PATCH] Adjust `source` return value, to return `wifi` when `media_app_name` is `AirPlay` or `Spotify` --- CHANGELOG.md | 1 + .../samsung_soundbar/api_extension/SoundbarDevice.py | 2 ++ custom_components/samsung_soundbar/media_player.py | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8735f4..7a7a0bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Change "magic numbers" to `MediaPlayerEntityFeature` object For more information see https://developers.home-assistant.io/blog/2023/12/28/support-feature-magic-numbers-deprecation +- the `source` now returns the value `wifi` when the `media_app_name` is `AirPlay` or `Spotify` ## [0.2.1] Chore: Format repository - 2024-02-08 diff --git a/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py b/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py index 751d688..8ad4280 100644 --- a/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py +++ b/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py @@ -242,6 +242,8 @@ class SoundbarDevice: @property def input_source(self): + if self.media_app_name in ("AirPlay", "Spotify"): + return "wifi" return self.device.status.input_source @property diff --git a/custom_components/samsung_soundbar/media_player.py b/custom_components/samsung_soundbar/media_player.py index e63f701..09a6109 100644 --- a/custom_components/samsung_soundbar/media_player.py +++ b/custom_components/samsung_soundbar/media_player.py @@ -3,7 +3,8 @@ from typing import Any, Mapping from homeassistant.components.media_player import (DEVICE_CLASS_SPEAKER, MediaPlayerEntity) -from homeassistant.components.media_player.const import MediaPlayerEntityFeature +from homeassistant.components.media_player.const import \ + MediaPlayerEntityFeature from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.entity import DeviceInfo, generate_entity_id