mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
use own track_utc_time_change to poll every 5 seconds
This commit is contained in:
parent
c3dd94ba04
commit
e9367d5369
@ -22,6 +22,7 @@ from homeassistant.components.media_player import (
|
|||||||
SUPPORT_VOLUME_MUTE, SUPPORT_PREVIOUS_TRACK, SUPPORT_NEXT_TRACK,
|
SUPPORT_VOLUME_MUTE, SUPPORT_PREVIOUS_TRACK, SUPPORT_NEXT_TRACK,
|
||||||
MEDIA_TYPE_MUSIC)
|
MEDIA_TYPE_MUSIC)
|
||||||
|
|
||||||
|
from homeassistant.helpers.event import track_utc_time_change
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
STATE_IDLE, STATE_PLAYING, STATE_PAUSED, STATE_UNKNOWN)
|
STATE_IDLE, STATE_PLAYING, STATE_PAUSED, STATE_UNKNOWN)
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
""" Sets up the Sonos platform. """
|
""" Sets up the Sonos platform. """
|
||||||
|
|
||||||
import soco
|
import soco
|
||||||
add_devices(SonosDevice(p) for p in soco.discover())
|
add_devices(SonosDevice(hass, p) for p in soco.discover())
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -48,14 +49,18 @@ class SonosDevice(MediaPlayerDevice):
|
|||||||
""" Represents a Sonos device. """
|
""" Represents a Sonos device. """
|
||||||
|
|
||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments
|
||||||
def __init__(self, player):
|
def __init__(self, hass, player):
|
||||||
super(SonosDevice, self).__init__()
|
super(SonosDevice, self).__init__()
|
||||||
self._player = player
|
self._player = player
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
track_utc_time_change(
|
||||||
|
hass, self.update_ha_state,
|
||||||
|
second=range(0, 60, 5))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
return True
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user