From 3cd85adb1a59c7beb6e453e53f65d6803f90d004 Mon Sep 17 00:00:00 2001 From: samuelspagl Date: Thu, 8 Feb 2024 16:30:17 +0100 Subject: [PATCH] Update Changelog, fix bug --- .gitignore | 1 + CHANGELOG.md | 18 +++++++++ .../samsung_soundbar/media_player.py | 37 ++++++++++++++----- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index cc66de8..d9c982e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ __pycache__/ *.py[cod] *$py.class +.DS_store # C extensions *.so diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29..636180f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1,18 @@ +# Changelog + +## [0.2.0] Add volume sensor - 2024-02-08 + +### Added + +- add new sensor entity for the volume + +### Fix + +- remove `extra_state_attributes` from `media_player` instance: + The property caused some unwanted side-effects on some systems. + +## [0.1.0] 🎉 First Version + +### Added + +- first version, gonna extend this Changelog sometime :D \ No newline at end of file diff --git a/custom_components/samsung_soundbar/media_player.py b/custom_components/samsung_soundbar/media_player.py index 06f9e37..9efcbda 100644 --- a/custom_components/samsung_soundbar/media_player.py +++ b/custom_components/samsung_soundbar/media_player.py @@ -1,18 +1,33 @@ import logging from typing import Any, Mapping -from homeassistant.components.media_player import (DEVICE_CLASS_SPEAKER, - MediaPlayerEntity) +from homeassistant.components.media_player import ( + DEVICE_CLASS_SPEAKER, + MediaPlayerEntity, +) from homeassistant.components.media_player.const import ( - SUPPORT_PAUSE, SUPPORT_PLAY, SUPPORT_SELECT_SOUND_MODE, - SUPPORT_SELECT_SOURCE, SUPPORT_STOP, SUPPORT_TURN_OFF, SUPPORT_TURN_ON, - SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, SUPPORT_VOLUME_STEP) + SUPPORT_PAUSE, + SUPPORT_PLAY, + SUPPORT_SELECT_SOUND_MODE, + SUPPORT_SELECT_SOURCE, + SUPPORT_STOP, + SUPPORT_TURN_OFF, + SUPPORT_TURN_ON, + SUPPORT_VOLUME_MUTE, + SUPPORT_VOLUME_SET, + SUPPORT_VOLUME_STEP, +) from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.entity import DeviceInfo, generate_entity_id from .api_extension.SoundbarDevice import SoundbarDevice -from .const import (CONF_ENTRY_API_KEY, CONF_ENTRY_DEVICE_ID, - CONF_ENTRY_DEVICE_NAME, CONF_ENTRY_MAX_VOLUME, DOMAIN) +from .const import ( + CONF_ENTRY_API_KEY, + CONF_ENTRY_DEVICE_ID, + CONF_ENTRY_DEVICE_NAME, + CONF_ENTRY_MAX_VOLUME, + DOMAIN, +) from .models import DeviceConfig _LOGGER = logging.getLogger(__name__) @@ -176,6 +191,8 @@ async def async_media_pause(self): async def async_media_stop(self): await self.device.media_stop() - @property - def extra_state_attributes(self) -> Mapping[str, Any] | None: - return {"device_information": self.device.retrieve_data} + # This property can be uncommented for some extra_attributes + # Still enabling this can cause side-effects. + # @property + # def extra_state_attributes(self) -> Mapping[str, Any] | None: + # return {"device_information": self.device.retrieve_data}