Add MediaPlayer Capabilities
This commit is contained in:
parent
00eccac431
commit
08e8f2645d
|
@ -9,6 +9,11 @@
|
||||||
- "woofer" feature
|
- "woofer" feature
|
||||||
- "soundmode" feature
|
- "soundmode" feature
|
||||||
- "eq" feature
|
- "eq" feature
|
||||||
|
- added `media_player` support for next and previous track
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Fixed state, also displaying "playing" and "paused" values
|
||||||
|
|
||||||
## [0.3.2] Fix division by zero
|
## [0.3.2] Fix division by zero
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,15 @@ class SoundbarDevice:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self) -> str:
|
def state(self) -> str:
|
||||||
return "on" if self.device.status.switch else "off"
|
if self.device.status.switch:
|
||||||
|
if self.device.status.playback_status == "playing":
|
||||||
|
return "playing"
|
||||||
|
if self.device.status.playback_status == "paused":
|
||||||
|
return "paused"
|
||||||
|
else:
|
||||||
|
return "on"
|
||||||
|
else:
|
||||||
|
return "off"
|
||||||
|
|
||||||
async def switch_off(self):
|
async def switch_off(self):
|
||||||
await self.device.switch_off(True)
|
await self.device.switch_off(True)
|
||||||
|
@ -377,6 +385,12 @@ class SoundbarDevice:
|
||||||
async def media_stop(self):
|
async def media_stop(self):
|
||||||
await self.device.stop(True)
|
await self.device.stop(True)
|
||||||
|
|
||||||
|
async def media_next_track(self):
|
||||||
|
await self.device.command("main", "mediaPlayback", "fastForward")
|
||||||
|
|
||||||
|
async def media_previous_track(self):
|
||||||
|
await self.device.command("main", "mediaPlayback", "rewind")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_app_name(self):
|
def media_app_name(self):
|
||||||
detail_status = self.device.status.attributes.get("detailName", None)
|
detail_status = self.device.status.attributes.get("detailName", None)
|
||||||
|
|
|
@ -33,6 +33,8 @@ SUPPORT_SMARTTHINGS_SOUNDBAR = (
|
||||||
| MediaPlayerEntityFeature.TURN_OFF
|
| MediaPlayerEntityFeature.TURN_OFF
|
||||||
| MediaPlayerEntityFeature.TURN_ON
|
| MediaPlayerEntityFeature.TURN_ON
|
||||||
| MediaPlayerEntityFeature.PLAY
|
| MediaPlayerEntityFeature.PLAY
|
||||||
|
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||||
|
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||||
| MediaPlayerEntityFeature.STOP
|
| MediaPlayerEntityFeature.STOP
|
||||||
| MediaPlayerEntityFeature.SELECT_SOUND_MODE
|
| MediaPlayerEntityFeature.SELECT_SOUND_MODE
|
||||||
)
|
)
|
||||||
|
@ -177,6 +179,12 @@ class SmartThingsSoundbarMediaPlayer(MediaPlayerEntity):
|
||||||
async def async_media_pause(self):
|
async def async_media_pause(self):
|
||||||
await self.device.media_pause()
|
await self.device.media_pause()
|
||||||
|
|
||||||
|
async def async_media_next_track(self):
|
||||||
|
await self.device.media_next_track()
|
||||||
|
|
||||||
|
async def async_media_previous_track(self):
|
||||||
|
await self.device.media_previous_track()
|
||||||
|
|
||||||
async def async_media_stop(self):
|
async def async_media_stop(self):
|
||||||
await self.device.media_stop()
|
await self.device.media_stop()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue