mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Introduce media progress for Yamaha Musiccast devices (#10256)
* Introduce update_hass() * Introduce media_positions * Version bump pymusiccast * Fix: Unnecessary "else" after "return" * FIX D400: First line should end with a period * Version bump Fixes https://github.com/home-assistant/home-assistant/issues/10411
This commit is contained in:
parent
16dd90ac78
commit
1c36e2f586
@ -10,10 +10,11 @@ media_player:
|
||||
import logging
|
||||
import voluptuous as vol
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from homeassistant.const import (
|
||||
CONF_HOST, CONF_PORT,
|
||||
STATE_UNKNOWN, STATE_ON
|
||||
STATE_UNKNOWN, STATE_ON, STATE_PLAYING, STATE_PAUSED, STATE_IDLE
|
||||
)
|
||||
from homeassistant.components.media_player import (
|
||||
MediaPlayerDevice, MEDIA_TYPE_MUSIC, PLATFORM_SCHEMA,
|
||||
@ -35,7 +36,7 @@ SUPPORTED_FEATURES = (
|
||||
KNOWN_HOSTS_KEY = 'data_yamaha_musiccast'
|
||||
INTERVAL_SECONDS = 'interval_seconds'
|
||||
|
||||
REQUIREMENTS = ['pymusiccast==0.1.3']
|
||||
REQUIREMENTS = ['pymusiccast==0.1.5']
|
||||
|
||||
DEFAULT_PORT = 5005
|
||||
DEFAULT_INTERVAL = 480
|
||||
@ -111,6 +112,7 @@ class YamahaDevice(MediaPlayerDevice):
|
||||
self._zone = zone
|
||||
self.mute = False
|
||||
self.media_status = None
|
||||
self.media_status_received = None
|
||||
self.power = STATE_UNKNOWN
|
||||
self.status = STATE_UNKNOWN
|
||||
self.volume = 0
|
||||
@ -202,12 +204,34 @@ class YamahaDevice(MediaPlayerDevice):
|
||||
"""Title of current playing media."""
|
||||
return self.media_status.media_title if self.media_status else None
|
||||
|
||||
@property
|
||||
def media_position(self):
|
||||
"""Position of current playing media in seconds."""
|
||||
if self.media_status and self.state in \
|
||||
[STATE_PLAYING, STATE_PAUSED, STATE_IDLE]:
|
||||
return self.media_status.media_position
|
||||
|
||||
@property
|
||||
def media_position_updated_at(self):
|
||||
"""When was the position of the current playing media valid.
|
||||
|
||||
Returns value from homeassistant.util.dt.utcnow().
|
||||
"""
|
||||
return self.media_status_received if self.media_status else None
|
||||
|
||||
def update(self):
|
||||
"""Get the latest details from the device."""
|
||||
_LOGGER.debug("update: %s", self.entity_id)
|
||||
self._recv.update_status()
|
||||
self._zone.update_status()
|
||||
|
||||
def update_hass(self):
|
||||
"""Push updates to HASS."""
|
||||
if self.entity_id:
|
||||
_LOGGER.debug("update_hass: pushing updates")
|
||||
self.schedule_update_ha_state()
|
||||
return True
|
||||
|
||||
def turn_on(self):
|
||||
"""Turn on specified media player or all."""
|
||||
_LOGGER.debug("Turn device: on")
|
||||
@ -259,3 +283,9 @@ class YamahaDevice(MediaPlayerDevice):
|
||||
_LOGGER.debug("select_source: %s", source)
|
||||
self.status = STATE_UNKNOWN
|
||||
self._zone.set_input(source)
|
||||
|
||||
def new_media_status(self, status):
|
||||
"""Handle updates of the media status."""
|
||||
_LOGGER.debug("new media_status arrived")
|
||||
self.media_status = status
|
||||
self.media_status_received = dt_util.utcnow()
|
||||
|
@ -730,7 +730,7 @@ pymodbus==1.3.1
|
||||
pymonoprice==0.2
|
||||
|
||||
# homeassistant.components.media_player.yamaha_musiccast
|
||||
pymusiccast==0.1.3
|
||||
pymusiccast==0.1.5
|
||||
|
||||
# homeassistant.components.cover.myq
|
||||
pymyq==0.0.8
|
||||
|
Loading…
x
Reference in New Issue
Block a user