parent
b4be508741
commit
9b3403943c
2 changed files with 30 additions and 8 deletions
|
@ -9,12 +9,16 @@ import logging
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
from homeassistant.components.media_player import (
|
from homeassistant.components.media_player import (
|
||||||
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, MediaPlayerDevice)
|
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, SUPPORT_SELECT_SOURCE,
|
||||||
from homeassistant.const import STATE_OFF, STATE_ON
|
MediaPlayerDevice)
|
||||||
|
from homeassistant.const import (
|
||||||
|
STATE_OFF, STATE_IDLE, STATE_PLAYING, STATE_UNKNOWN)
|
||||||
|
|
||||||
|
SUPPORT_SNAPCAST = SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
|
||||||
|
SUPPORT_SELECT_SOURCE
|
||||||
|
|
||||||
SUPPORT_SNAPCAST = SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE
|
|
||||||
DOMAIN = 'snapcast'
|
DOMAIN = 'snapcast'
|
||||||
REQUIREMENTS = ['snapcast==1.1.1']
|
REQUIREMENTS = ['snapcast==1.2.1']
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,9 +71,23 @@ class SnapcastDevice(MediaPlayerDevice):
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the player."""
|
"""Return the state of the player."""
|
||||||
if self._client.connected:
|
if not self._client.connected:
|
||||||
return STATE_ON
|
return STATE_OFF
|
||||||
return STATE_OFF
|
return {
|
||||||
|
'idle': STATE_IDLE,
|
||||||
|
'playing': STATE_PLAYING,
|
||||||
|
'unkown': STATE_UNKNOWN,
|
||||||
|
}.get(self._client.stream.status, STATE_UNKNOWN)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def source(self):
|
||||||
|
"""Return the current input source."""
|
||||||
|
return self._client.stream.identifier
|
||||||
|
|
||||||
|
@property
|
||||||
|
def source_list(self):
|
||||||
|
"""List of available input sources."""
|
||||||
|
return self._client.available_streams()
|
||||||
|
|
||||||
def mute_volume(self, mute):
|
def mute_volume(self, mute):
|
||||||
"""Send the mute command."""
|
"""Send the mute command."""
|
||||||
|
@ -78,3 +96,7 @@ class SnapcastDevice(MediaPlayerDevice):
|
||||||
def set_volume_level(self, volume):
|
def set_volume_level(self, volume):
|
||||||
"""Set the volume level."""
|
"""Set the volume level."""
|
||||||
self._client.volume = round(volume * 100)
|
self._client.volume = round(volume * 100)
|
||||||
|
|
||||||
|
def select_source(self, source):
|
||||||
|
"""Set input source."""
|
||||||
|
self._client.stream = source
|
||||||
|
|
|
@ -294,7 +294,7 @@ slacker==0.9.10
|
||||||
sleekxmpp==1.3.1
|
sleekxmpp==1.3.1
|
||||||
|
|
||||||
# homeassistant.components.media_player.snapcast
|
# homeassistant.components.media_player.snapcast
|
||||||
snapcast==1.1.1
|
snapcast==1.2.1
|
||||||
|
|
||||||
# homeassistant.components.thermostat.honeywell
|
# homeassistant.components.thermostat.honeywell
|
||||||
somecomfort==0.2.1
|
somecomfort==0.2.1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue