1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00

Show media progress in sisyphus (#42996)

This is newly possible in recent Sisyphus table firmwares. If it doesn't work for you, make sure you're running at least firmware 1.10.73.
This commit is contained in:
Jonathan Keljo 2020-11-11 05:52:34 -08:00 committed by GitHub
parent 560afc31ad
commit 8f59104c71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -38,6 +38,10 @@ class SisyphusLight(LightEntity):
"""Add listeners after this object has been initialized."""
self._table.add_listener(self.async_write_ha_state)
async def async_update(self):
"""Force update the table state."""
await self._table.refresh()
@property
def available(self):
"""Return true if the table is responding to heartbeats."""

View File

@ -65,6 +65,10 @@ class SisyphusPlayer(MediaPlayerEntity):
"""Add listeners after this object has been initialized."""
self._table.add_listener(self.async_write_ha_state)
async def async_update(self):
"""Force update table state."""
await self._table.refresh()
@property
def unique_id(self):
"""Return the UUID of the table."""
@ -129,6 +133,24 @@ class SisyphusPlayer(MediaPlayerEntity):
"""Return the track ID of the current track."""
return self._table.active_track.id if self._table.active_track else None
@property
def media_duration(self):
"""Return the total time it will take to run this track at the current speed."""
return self._table.active_track_total_time.total_seconds()
@property
def media_position(self):
"""Return the current position within the track."""
return (
self._table.active_track_total_time
- self._table.active_track_remaining_time
).total_seconds()
@property
def media_position_updated_at(self):
"""Return the last time we got a position update."""
return self._table.active_track_remaining_time_as_of
@property
def supported_features(self):
"""Return the features supported by this table."""