Skip to content

Commit

Permalink
Update ordering (#3216)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabaff authored Sep 5, 2016
1 parent 73036f4 commit 5ec6eaf
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions homeassistant/components/media_player/snapcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,29 @@
"""
import logging
import socket

import voluptuous as vol
import homeassistant.helpers.config_validation as cv

from homeassistant.components.media_player import (
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, SUPPORT_SELECT_SOURCE,
PLATFORM_SCHEMA, MediaPlayerDevice)
from homeassistant.const import (
STATE_OFF, STATE_IDLE, STATE_PLAYING, STATE_UNKNOWN,
CONF_HOST, CONF_PORT)
STATE_OFF, STATE_IDLE, STATE_PLAYING, STATE_UNKNOWN, CONF_HOST, CONF_PORT)
import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['snapcast==1.2.2']

_LOGGER = logging.getLogger(__name__)

DOMAIN = 'snapcast'

SUPPORT_SNAPCAST = SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
SUPPORT_SELECT_SOURCE

DOMAIN = 'snapcast'
REQUIREMENTS = ['snapcast==1.2.2']
_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_PORT): cv.port
vol.Optional(CONF_PORT): cv.port,
})


Expand All @@ -35,12 +38,14 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
import snapcast.control
host = config.get(CONF_HOST)
port = config.get(CONF_PORT, snapcast.control.CONTROL_PORT)

try:
server = snapcast.control.Snapserver(host, port)
except socket.gaierror:
_LOGGER.error('Could not connect to Snapcast server at %s:%d',
host, port)
return
return False

add_devices([SnapcastDevice(client) for client in server.clients])


Expand Down

0 comments on commit 5ec6eaf

Please sign in to comment.