Skip to content

Commit

Permalink
Update Changelog, fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelspagl committed Feb 8, 2024
1 parent c61b2ba commit 3cd85ad
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
__pycache__/
*.py[cod]
*$py.class
.DS_store

# C extensions
*.so
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
37 changes: 27 additions & 10 deletions custom_components/samsung_soundbar/media_player.py
Original file line number Diff line number Diff line change
@@ -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__)
Expand Down Expand Up @@ -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}

0 comments on commit 3cd85ad

Please sign in to comment.