Update Changelog, fix bug

This commit is contained in:
samuelspagl 2024-02-08 16:30:17 +01:00
parent c61b2ba3f2
commit 3cd85adb1a
3 changed files with 46 additions and 10 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
__pycache__/ __pycache__/
*.py[cod] *.py[cod]
*$py.class *$py.class
.DS_store
# C extensions # C extensions
*.so *.so

View File

@ -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

View File

@ -1,18 +1,33 @@
import logging import logging
from typing import Any, Mapping from typing import Any, Mapping
from homeassistant.components.media_player import (DEVICE_CLASS_SPEAKER, from homeassistant.components.media_player import (
MediaPlayerEntity) DEVICE_CLASS_SPEAKER,
MediaPlayerEntity,
)
from homeassistant.components.media_player.const import ( from homeassistant.components.media_player.const import (
SUPPORT_PAUSE, SUPPORT_PLAY, SUPPORT_SELECT_SOUND_MODE, SUPPORT_PAUSE,
SUPPORT_SELECT_SOURCE, SUPPORT_STOP, SUPPORT_TURN_OFF, SUPPORT_TURN_ON, SUPPORT_PLAY,
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, SUPPORT_VOLUME_STEP) 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.aiohttp_client import async_get_clientsession
from homeassistant.helpers.entity import DeviceInfo, generate_entity_id from homeassistant.helpers.entity import DeviceInfo, generate_entity_id
from .api_extension.SoundbarDevice import SoundbarDevice from .api_extension.SoundbarDevice import SoundbarDevice
from .const import (CONF_ENTRY_API_KEY, CONF_ENTRY_DEVICE_ID, from .const import (
CONF_ENTRY_DEVICE_NAME, CONF_ENTRY_MAX_VOLUME, DOMAIN) CONF_ENTRY_API_KEY,
CONF_ENTRY_DEVICE_ID,
CONF_ENTRY_DEVICE_NAME,
CONF_ENTRY_MAX_VOLUME,
DOMAIN,
)
from .models import DeviceConfig from .models import DeviceConfig
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -176,6 +191,8 @@ class SmartThingsSoundbarMediaPlayer(MediaPlayerEntity):
async def async_media_stop(self): async def async_media_stop(self):
await self.device.media_stop() await self.device.media_stop()
@property # This property can be uncommented for some extra_attributes
def extra_state_attributes(self) -> Mapping[str, Any] | None: # Still enabling this can cause side-effects.
return {"device_information": self.device.retrieve_data} # @property
# def extra_state_attributes(self) -> Mapping[str, Any] | None:
# return {"device_information": self.device.retrieve_data}