Merge pull request #4235 from home-assistant/release-0-32-1

0.32.1
This commit is contained in:
Paulus Schoutsen 2016-11-05 17:09:10 -07:00 committed by GitHub
commit 08f75f7935
8 changed files with 41 additions and 30 deletions

View File

@ -101,7 +101,6 @@ class Camera(Entity):
response.content_type = ('multipart/x-mixed-replace; ' response.content_type = ('multipart/x-mixed-replace; '
'boundary=--jpegboundary') 'boundary=--jpegboundary')
response.enable_chunked_encoding()
yield from response.prepare(request) yield from response.prepare(request)
def write(img_bytes): def write(img_bytes):

View File

@ -75,7 +75,6 @@ class FFmpegCamera(Camera):
response = web.StreamResponse() response = web.StreamResponse()
response.content_type = 'multipart/x-mixed-replace;boundary=ffserver' response.content_type = 'multipart/x-mixed-replace;boundary=ffserver'
response.enable_chunked_encoding()
yield from response.prepare(request) yield from response.prepare(request)

View File

@ -112,7 +112,6 @@ class MjpegCamera(Camera):
response = web.StreamResponse() response = web.StreamResponse()
response.content_type = stream.headers.get(CONTENT_TYPE_HEADER) response.content_type = stream.headers.get(CONTENT_TYPE_HEADER)
response.enable_chunked_encoding()
yield from response.prepare(request) yield from response.prepare(request)

View File

@ -271,7 +271,6 @@ class SynologyCamera(Camera):
response = web.StreamResponse() response = web.StreamResponse()
response.content_type = stream.headers.get(CONTENT_TYPE_HEADER) response.content_type = stream.headers.get(CONTENT_TYPE_HEADER)
response.enable_chunked_encoding()
yield from response.prepare(request) yield from response.prepare(request)

View File

@ -69,6 +69,8 @@ class RadioThermostat(ClimateDevice):
self._current_temperature = None self._current_temperature = None
self._current_operation = STATE_IDLE self._current_operation = STATE_IDLE
self._name = None self._name = None
self._fmode = None
self._tmode = None
self.hold_temp = hold_temp self.hold_temp = hold_temp
self.update() self.update()
self._operation_list = [STATE_AUTO, STATE_COOL, STATE_HEAT, STATE_OFF] self._operation_list = [STATE_AUTO, STATE_COOL, STATE_HEAT, STATE_OFF]
@ -87,8 +89,8 @@ class RadioThermostat(ClimateDevice):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the device specific state attributes.""" """Return the device specific state attributes."""
return { return {
ATTR_FAN: self.device.fmode['human'], ATTR_FAN: self._fmode,
ATTR_MODE: self.device.tmode['human'] ATTR_MODE: self._tmode,
} }
@property @property
@ -115,10 +117,13 @@ class RadioThermostat(ClimateDevice):
"""Update the data from the thermostat.""" """Update the data from the thermostat."""
self._current_temperature = self.device.temp['raw'] self._current_temperature = self.device.temp['raw']
self._name = self.device.name['raw'] self._name = self.device.name['raw']
if self.device.tmode['human'] == 'Cool': self._fmode = self.device.fmode['human']
self._tmode = self.device.tmode['human']
if self._tmode == 'Cool':
self._target_temperature = self.device.t_cool['raw'] self._target_temperature = self.device.t_cool['raw']
self._current_operation = STATE_COOL self._current_operation = STATE_COOL
elif self.device.tmode['human'] == 'Heat': elif self._tmode == 'Heat':
self._target_temperature = self.device.t_heat['raw'] self._target_temperature = self.device.t_heat['raw']
self._current_operation = STATE_HEAT self._current_operation = STATE_HEAT
else: else:

View File

@ -80,7 +80,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
if player.is_visible: if player.is_visible:
device = SonosDevice(hass, player) device = SonosDevice(hass, player)
add_devices([device]) add_devices([device], True)
if not DEVICES: if not DEVICES:
register_services(hass) register_services(hass)
DEVICES.append(device) DEVICES.append(device)
@ -106,7 +106,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
return False return False
DEVICES = [SonosDevice(hass, p) for p in players] DEVICES = [SonosDevice(hass, p) for p in players]
add_devices(DEVICES) add_devices(DEVICES, True)
register_services(hass) register_services(hass)
_LOGGER.info('Added %s Sonos speakers', len(players)) _LOGGER.info('Added %s Sonos speakers', len(players))
return True return True
@ -256,6 +256,7 @@ class SonosDevice(MediaPlayerDevice):
self.hass = hass self.hass = hass
self.volume_increment = 5 self.volume_increment = 5
self._unique_id = player.uid
self._player = player self._player = player
self._player_volume = None self._player_volume = None
self._player_volume_muted = None self._player_volume_muted = None
@ -278,7 +279,8 @@ class SonosDevice(MediaPlayerDevice):
self._current_track_is_radio_stream = False self._current_track_is_radio_stream = False
self._queue = None self._queue = None
self._last_avtransport_event = None self._last_avtransport_event = None
self.update() self._is_playing_line_in = None
self._is_playing_tv = None
self.soco_snapshot = Snapshot(self._player) self.soco_snapshot = Snapshot(self._player)
@property @property
@ -286,14 +288,10 @@ class SonosDevice(MediaPlayerDevice):
"""Polling needed.""" """Polling needed."""
return True return True
def update_sonos(self, now):
"""Update state, called by track_utc_time_change."""
self.update_ha_state(True)
@property @property
def unique_id(self): def unique_id(self):
"""Return an unique ID.""" """Return an unique ID."""
return self._player.uid return self._unique_id
@property @property
def name(self): def name(self):
@ -354,6 +352,9 @@ class SonosDevice(MediaPlayerDevice):
if is_available: if is_available:
self._is_playing_tv = self._player.is_playing_tv
self._is_playing_line_in = self._player.is_playing_line_in
track_info = None track_info = None
if self._last_avtransport_event: if self._last_avtransport_event:
variables = self._last_avtransport_event.variables variables = self._last_avtransport_event.variables
@ -511,10 +512,10 @@ class SonosDevice(MediaPlayerDevice):
# update state of the whole group # update state of the whole group
# pylint: disable=protected-access # pylint: disable=protected-access
for device in [x for x in DEVICES if x._coordinator == self]: for device in [x for x in DEVICES if x._coordinator == self]:
if device.entity_id: if device.entity_id is not self.entity_id:
device.update_ha_state(False) self.hass.add_job(device.async_update_ha_state)
if self._queue is None and self.entity_id: if self._queue is None:
self._subscribe_to_player_events() self._subscribe_to_player_events()
else: else:
self._player_volume = None self._player_volume = None
@ -534,6 +535,8 @@ class SonosDevice(MediaPlayerDevice):
self._support_previous_track = False self._support_previous_track = False
self._support_next_track = False self._support_next_track = False
self._support_pause = False self._support_pause = False
self._is_playing_tv = False
self._is_playing_line_in = False
self._last_avtransport_event = None self._last_avtransport_event = None
@ -713,9 +716,9 @@ class SonosDevice(MediaPlayerDevice):
@property @property
def source(self): def source(self):
"""Name of the current input source.""" """Name of the current input source."""
if self._player.is_playing_line_in: if self._is_playing_line_in:
return SUPPORT_SOURCE_LINEIN return SUPPORT_SOURCE_LINEIN
if self._player.is_playing_tv: if self._is_playing_tv:
return SUPPORT_SOURCE_TV return SUPPORT_SOURCE_TV
return None return None

View File

@ -2,7 +2,7 @@
"""Constants used by Home Assistant components.""" """Constants used by Home Assistant components."""
MAJOR_VERSION = 0 MAJOR_VERSION = 0
MINOR_VERSION = 32 MINOR_VERSION = 32
PATCH_VERSION = '0' PATCH_VERSION = '1'
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
REQUIRED_PYTHON_VER = (3, 4, 2) REQUIRED_PYTHON_VER = (3, 4, 2)

View File

@ -92,6 +92,13 @@ class SoCoMock():
return "RINCON_XXXXXXXXXXXXXXXXX" return "RINCON_XXXXXXXXXXXXXXXXX"
def fake_add_device(devices, update_befor_add=False):
"""Fake add device / update."""
if update_befor_add:
for speaker in devices:
speaker.update()
class TestSonosMediaPlayer(unittest.TestCase): class TestSonosMediaPlayer(unittest.TestCase):
"""Test the media_player module.""" """Test the media_player module."""
@ -117,7 +124,7 @@ class TestSonosMediaPlayer(unittest.TestCase):
@mock.patch('socket.create_connection', side_effect=socket.error()) @mock.patch('socket.create_connection', side_effect=socket.error())
def test_ensure_setup_discovery(self, *args): def test_ensure_setup_discovery(self, *args):
"""Test a single device using the autodiscovery provided by HASS.""" """Test a single device using the autodiscovery provided by HASS."""
sonos.setup_platform(self.hass, {}, mock.MagicMock(), '192.0.2.1') sonos.setup_platform(self.hass, {}, fake_add_device, '192.0.2.1')
# Ensure registration took place (#2558) # Ensure registration took place (#2558)
self.assertEqual(len(sonos.DEVICES), 1) self.assertEqual(len(sonos.DEVICES), 1)
@ -129,7 +136,7 @@ class TestSonosMediaPlayer(unittest.TestCase):
"""Test a single address config'd by the HASS config file.""" """Test a single address config'd by the HASS config file."""
sonos.setup_platform(self.hass, sonos.setup_platform(self.hass,
{'hosts': '192.0.2.1'}, {'hosts': '192.0.2.1'},
mock.MagicMock()) fake_add_device)
# Ensure registration took place (#2558) # Ensure registration took place (#2558)
self.assertEqual(len(sonos.DEVICES), 1) self.assertEqual(len(sonos.DEVICES), 1)
@ -140,7 +147,7 @@ class TestSonosMediaPlayer(unittest.TestCase):
@mock.patch('socket.create_connection', side_effect=socket.error()) @mock.patch('socket.create_connection', side_effect=socket.error())
def test_ensure_setup_sonos_discovery(self, *args): def test_ensure_setup_sonos_discovery(self, *args):
"""Test a single device using the autodiscovery provided by Sonos.""" """Test a single device using the autodiscovery provided by Sonos."""
sonos.setup_platform(self.hass, {}, mock.MagicMock()) sonos.setup_platform(self.hass, {}, fake_add_device)
self.assertEqual(len(sonos.DEVICES), 1) self.assertEqual(len(sonos.DEVICES), 1)
self.assertEqual(sonos.DEVICES[0].name, 'Kitchen') self.assertEqual(sonos.DEVICES[0].name, 'Kitchen')
@ -149,7 +156,7 @@ class TestSonosMediaPlayer(unittest.TestCase):
@mock.patch.object(SoCoMock, 'partymode') @mock.patch.object(SoCoMock, 'partymode')
def test_sonos_group_players(self, partymodeMock, *args): def test_sonos_group_players(self, partymodeMock, *args):
"""Ensuring soco methods called for sonos_group_players service.""" """Ensuring soco methods called for sonos_group_players service."""
sonos.setup_platform(self.hass, {}, mock.MagicMock(), '192.0.2.1') sonos.setup_platform(self.hass, {}, fake_add_device, '192.0.2.1')
device = sonos.DEVICES[-1] device = sonos.DEVICES[-1]
partymodeMock.return_value = True partymodeMock.return_value = True
device.group_players() device.group_players()
@ -161,7 +168,7 @@ class TestSonosMediaPlayer(unittest.TestCase):
@mock.patch.object(SoCoMock, 'unjoin') @mock.patch.object(SoCoMock, 'unjoin')
def test_sonos_unjoin(self, unjoinMock, *args): def test_sonos_unjoin(self, unjoinMock, *args):
"""Ensuring soco methods called for sonos_unjoin service.""" """Ensuring soco methods called for sonos_unjoin service."""
sonos.setup_platform(self.hass, {}, mock.MagicMock(), '192.0.2.1') sonos.setup_platform(self.hass, {}, fake_add_device, '192.0.2.1')
device = sonos.DEVICES[-1] device = sonos.DEVICES[-1]
unjoinMock.return_value = True unjoinMock.return_value = True
device.unjoin() device.unjoin()
@ -173,7 +180,7 @@ class TestSonosMediaPlayer(unittest.TestCase):
@mock.patch.object(SoCoMock, 'set_sleep_timer') @mock.patch.object(SoCoMock, 'set_sleep_timer')
def test_sonos_set_sleep_timer(self, set_sleep_timerMock, *args): def test_sonos_set_sleep_timer(self, set_sleep_timerMock, *args):
"""Ensuring soco methods called for sonos_set_sleep_timer service.""" """Ensuring soco methods called for sonos_set_sleep_timer service."""
sonos.setup_platform(self.hass, {}, mock.MagicMock(), '192.0.2.1') sonos.setup_platform(self.hass, {}, fake_add_device, '192.0.2.1')
device = sonos.DEVICES[-1] device = sonos.DEVICES[-1]
device.set_sleep_timer(30) device.set_sleep_timer(30)
set_sleep_timerMock.assert_called_once_with(30) set_sleep_timerMock.assert_called_once_with(30)
@ -193,7 +200,7 @@ class TestSonosMediaPlayer(unittest.TestCase):
@mock.patch.object(soco.snapshot.Snapshot, 'snapshot') @mock.patch.object(soco.snapshot.Snapshot, 'snapshot')
def test_sonos_snapshot(self, snapshotMock, *args): def test_sonos_snapshot(self, snapshotMock, *args):
"""Ensuring soco methods called for sonos_snapshot service.""" """Ensuring soco methods called for sonos_snapshot service."""
sonos.setup_platform(self.hass, {}, mock.MagicMock(), '192.0.2.1') sonos.setup_platform(self.hass, {}, fake_add_device, '192.0.2.1')
device = sonos.DEVICES[-1] device = sonos.DEVICES[-1]
snapshotMock.return_value = True snapshotMock.return_value = True
device.snapshot() device.snapshot()
@ -205,7 +212,7 @@ class TestSonosMediaPlayer(unittest.TestCase):
@mock.patch.object(soco.snapshot.Snapshot, 'restore') @mock.patch.object(soco.snapshot.Snapshot, 'restore')
def test_sonos_restore(self, restoreMock, *args): def test_sonos_restore(self, restoreMock, *args):
"""Ensuring soco methods called for sonos_restor service.""" """Ensuring soco methods called for sonos_restor service."""
sonos.setup_platform(self.hass, {}, mock.MagicMock(), '192.0.2.1') sonos.setup_platform(self.hass, {}, fake_add_device, '192.0.2.1')
device = sonos.DEVICES[-1] device = sonos.DEVICES[-1]
restoreMock.return_value = True restoreMock.return_value = True
device.restore() device.restore()