From de6fc53ca5a64fb63fef2a9c6b92342a14deb7e9 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 16 Apr 2020 16:59:30 -0500 Subject: [PATCH 1/9] Use config entry id for unique id if serial number is missing (#34154) --- homeassistant/components/nut/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/nut/__init__.py b/homeassistant/components/nut/__init__.py index b8561dde303..c8b794788a4 100644 --- a/homeassistant/components/nut/__init__.py +++ b/homeassistant/components/nut/__init__.py @@ -58,10 +58,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): _LOGGER.debug("NUT Sensors Available: %s", status) + unique_id = _unique_id_from_status(status) + + if unique_id is None: + unique_id = entry.entry_id + hass.data[DOMAIN][entry.entry_id] = { PYNUT_DATA: data, PYNUT_STATUS: status, - PYNUT_UNIQUE_ID: _unique_id_from_status(status), + PYNUT_UNIQUE_ID: unique_id, PYNUT_MANUFACTURER: _manufacturer_from_status(status), PYNUT_MODEL: _model_from_status(status), PYNUT_FIRMWARE: _firmware_from_status(status), From 8a8cbeb4c043aa45937d44dbde5babb212fe7381 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 16 Apr 2020 17:18:41 -0500 Subject: [PATCH 2/9] Fix default elkm1 temp units (#34274) --- homeassistant/components/elkm1/__init__.py | 15 +++++++++++++-- homeassistant/components/elkm1/climate.py | 4 ++-- homeassistant/components/elkm1/config_flow.py | 6 +++++- homeassistant/components/elkm1/const.py | 3 +++ tests/components/elkm1/test_config_flow.py | 16 ++++++++-------- 5 files changed, 31 insertions(+), 13 deletions(-) diff --git a/homeassistant/components/elkm1/__init__.py b/homeassistant/components/elkm1/__init__.py index 5c6fbf71738..946e40b7e23 100644 --- a/homeassistant/components/elkm1/__init__.py +++ b/homeassistant/components/elkm1/__init__.py @@ -15,6 +15,8 @@ from homeassistant.const import ( CONF_PASSWORD, CONF_TEMPERATURE_UNIT, CONF_USERNAME, + TEMP_CELSIUS, + TEMP_FAHRENHEIT, ) from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import ConfigEntryNotReady @@ -23,6 +25,8 @@ from homeassistant.helpers.entity import Entity from homeassistant.helpers.typing import ConfigType from .const import ( + BARE_TEMP_CELSIUS, + BARE_TEMP_FAHRENHEIT, CONF_AREA, CONF_AUTO_CONFIGURE, CONF_COUNTER, @@ -119,7 +123,10 @@ DEVICE_SCHEMA = vol.Schema( vol.Optional(CONF_USERNAME, default=""): cv.string, vol.Optional(CONF_PASSWORD, default=""): cv.string, vol.Optional(CONF_AUTO_CONFIGURE, default=False): cv.boolean, - vol.Optional(CONF_TEMPERATURE_UNIT, default="F"): cv.temperature_unit, + # cv.temperature_unit will mutate 'C' -> '°C' and 'F' -> '°F' + vol.Optional( + CONF_TEMPERATURE_UNIT, default=BARE_TEMP_FAHRENHEIT + ): cv.temperature_unit, vol.Optional(CONF_AREA, default={}): DEVICE_SCHEMA_SUBDOMAIN, vol.Optional(CONF_COUNTER, default={}): DEVICE_SCHEMA_SUBDOMAIN, vol.Optional(CONF_KEYPAD, default={}): DEVICE_SCHEMA_SUBDOMAIN, @@ -187,7 +194,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): _LOGGER.debug("Setting up elkm1 %s", conf["host"]) - config = {"temperature_unit": conf[CONF_TEMPERATURE_UNIT]} + temperature_unit = TEMP_FAHRENHEIT + if conf[CONF_TEMPERATURE_UNIT] in (BARE_TEMP_CELSIUS, TEMP_CELSIUS): + temperature_unit = TEMP_CELSIUS + + config = {"temperature_unit": temperature_unit} if not conf[CONF_AUTO_CONFIGURE]: # With elkm1-lib==0.7.16 and later auto configure is available diff --git a/homeassistant/components/elkm1/climate.py b/homeassistant/components/elkm1/climate.py index 3c5c70b2bd0..baaf3d44eb2 100644 --- a/homeassistant/components/elkm1/climate.py +++ b/homeassistant/components/elkm1/climate.py @@ -14,7 +14,7 @@ from homeassistant.components.climate.const import ( SUPPORT_FAN_MODE, SUPPORT_TARGET_TEMPERATURE_RANGE, ) -from homeassistant.const import PRECISION_WHOLE, STATE_ON, TEMP_CELSIUS, TEMP_FAHRENHEIT +from homeassistant.const import PRECISION_WHOLE, STATE_ON from . import ElkEntity, create_elk_entities from .const import DOMAIN @@ -55,7 +55,7 @@ class ElkThermostat(ElkEntity, ClimateDevice): @property def temperature_unit(self): """Return the temperature unit.""" - return TEMP_FAHRENHEIT if self._temperature_unit == "F" else TEMP_CELSIUS + return self._temperature_unit @property def current_temperature(self): diff --git a/homeassistant/components/elkm1/config_flow.py b/homeassistant/components/elkm1/config_flow.py index c96e6e549c0..419e4df7552 100644 --- a/homeassistant/components/elkm1/config_flow.py +++ b/homeassistant/components/elkm1/config_flow.py @@ -13,6 +13,8 @@ from homeassistant.const import ( CONF_PROTOCOL, CONF_TEMPERATURE_UNIT, CONF_USERNAME, + TEMP_CELSIUS, + TEMP_FAHRENHEIT, ) from homeassistant.util import slugify @@ -33,7 +35,9 @@ DATA_SCHEMA = vol.Schema( vol.Optional(CONF_USERNAME, default=""): str, vol.Optional(CONF_PASSWORD, default=""): str, vol.Optional(CONF_PREFIX, default=""): str, - vol.Optional(CONF_TEMPERATURE_UNIT, default="F"): vol.In(["F", "C"]), + vol.Optional(CONF_TEMPERATURE_UNIT, default=TEMP_FAHRENHEIT): vol.In( + [TEMP_FAHRENHEIT, TEMP_CELSIUS] + ), } ) diff --git a/homeassistant/components/elkm1/const.py b/homeassistant/components/elkm1/const.py index bad6d7fbcf1..3d9d433617d 100644 --- a/homeassistant/components/elkm1/const.py +++ b/homeassistant/components/elkm1/const.py @@ -18,6 +18,9 @@ CONF_ZONE = "zone" CONF_PREFIX = "prefix" +BARE_TEMP_FAHRENHEIT = "F" +BARE_TEMP_CELSIUS = "C" + ELK_ELEMENTS = { CONF_AREA: Max.AREAS.value, CONF_COUNTER: Max.COUNTERS.value, diff --git a/tests/components/elkm1/test_config_flow.py b/tests/components/elkm1/test_config_flow.py index 02e3fd7fce9..2f701a2e146 100644 --- a/tests/components/elkm1/test_config_flow.py +++ b/tests/components/elkm1/test_config_flow.py @@ -39,7 +39,7 @@ async def test_form_user_with_secure_elk(hass): "address": "1.2.3.4", "username": "test-username", "password": "test-password", - "temperature_unit": "F", + "temperature_unit": "°F", "prefix": "", }, ) @@ -51,7 +51,7 @@ async def test_form_user_with_secure_elk(hass): "host": "elks://1.2.3.4", "password": "test-password", "prefix": "", - "temperature_unit": "F", + "temperature_unit": "°F", "username": "test-username", } await hass.async_block_till_done() @@ -82,7 +82,7 @@ async def test_form_user_with_non_secure_elk(hass): { "protocol": "non-secure", "address": "1.2.3.4", - "temperature_unit": "F", + "temperature_unit": "°F", "prefix": "guest_house", }, ) @@ -95,7 +95,7 @@ async def test_form_user_with_non_secure_elk(hass): "prefix": "guest_house", "username": "", "password": "", - "temperature_unit": "F", + "temperature_unit": "°F", } await hass.async_block_till_done() assert len(mock_setup.mock_calls) == 1 @@ -125,7 +125,7 @@ async def test_form_user_with_serial_elk(hass): { "protocol": "serial", "address": "/dev/ttyS0:115200", - "temperature_unit": "F", + "temperature_unit": "°C", "prefix": "", }, ) @@ -138,7 +138,7 @@ async def test_form_user_with_serial_elk(hass): "prefix": "", "username": "", "password": "", - "temperature_unit": "F", + "temperature_unit": "°C", } await hass.async_block_till_done() assert len(mock_setup.mock_calls) == 1 @@ -166,7 +166,7 @@ async def test_form_cannot_connect(hass): "address": "1.2.3.4", "username": "test-username", "password": "test-password", - "temperature_unit": "F", + "temperature_unit": "°F", "prefix": "", }, ) @@ -193,7 +193,7 @@ async def test_form_invalid_auth(hass): "address": "1.2.3.4", "username": "test-username", "password": "test-password", - "temperature_unit": "F", + "temperature_unit": "°F", "prefix": "", }, ) From 5157c2d10c16b956af6d52f5e1f3a07e3c8c3d49 Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Thu, 16 Apr 2020 17:53:34 -0400 Subject: [PATCH 3/9] Skip ignored hosts when checking existing config entries in config flow (#34280) --- homeassistant/components/vizio/config_flow.py | 20 ++++- tests/components/vizio/test_config_flow.py | 73 ++++++++++++++++++- 2 files changed, 91 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/vizio/config_flow.py b/homeassistant/components/vizio/config_flow.py index 51f00ad98bb..eac6df85f43 100644 --- a/homeassistant/components/vizio/config_flow.py +++ b/homeassistant/components/vizio/config_flow.py @@ -8,7 +8,12 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.components.media_player import DEVICE_CLASS_SPEAKER, DEVICE_CLASS_TV -from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_ZEROCONF, ConfigEntry +from homeassistant.config_entries import ( + SOURCE_IGNORE, + SOURCE_IMPORT, + SOURCE_ZEROCONF, + ConfigEntry, +) from homeassistant.const import ( CONF_ACCESS_TOKEN, CONF_DEVICE_CLASS, @@ -198,8 +203,13 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): # Check if new config entry matches any existing config entries for entry in self.hass.config_entries.async_entries(DOMAIN): + # If source is ignore bypass host and name check and continue through loop + if entry.source == SOURCE_IGNORE: + continue + if _host_is_same(entry.data[CONF_HOST], user_input[CONF_HOST]): errors[CONF_HOST] = "host_exists" + if entry.data[CONF_NAME] == user_input[CONF_NAME]: errors[CONF_NAME] = "name_exists" @@ -270,6 +280,10 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): """Import a config entry from configuration.yaml.""" # Check if new config entry matches any existing config entries for entry in self.hass.config_entries.async_entries(DOMAIN): + # If source is ignore bypass host check and continue through loop + if entry.source == SOURCE_IGNORE: + continue + if _host_is_same(entry.data[CONF_HOST], import_config[CONF_HOST]): updated_options = {} updated_data = {} @@ -334,6 +348,10 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): # Check if new config entry matches any existing config entries and abort if so for entry in self.hass.config_entries.async_entries(DOMAIN): + # If source is ignore bypass host check and continue through loop + if entry.source == SOURCE_IGNORE: + continue + if _host_is_same(entry.data[CONF_HOST], discovery_info[CONF_HOST]): return self.async_abort(reason="already_setup") diff --git a/tests/components/vizio/test_config_flow.py b/tests/components/vizio/test_config_flow.py index b5b10534759..3cb22a22541 100644 --- a/tests/components/vizio/test_config_flow.py +++ b/tests/components/vizio/test_config_flow.py @@ -17,7 +17,12 @@ from homeassistant.components.vizio.const import ( DOMAIN, VIZIO_SCHEMA, ) -from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER, SOURCE_ZEROCONF +from homeassistant.config_entries import ( + SOURCE_IGNORE, + SOURCE_IMPORT, + SOURCE_USER, + SOURCE_ZEROCONF, +) from homeassistant.const import ( CONF_ACCESS_TOKEN, CONF_DEVICE_CLASS, @@ -383,6 +388,26 @@ async def test_user_invalid_pin( assert result["errors"] == {CONF_PIN: "complete_pairing_failed"} +async def test_user_ignore( + hass: HomeAssistantType, + vizio_connect: pytest.fixture, + vizio_bypass_setup: pytest.fixture, +) -> None: + """Test user config flow doesn't throw an error when there's an existing ignored source.""" + entry = MockConfigEntry( + domain=DOMAIN, + data=MOCK_SPEAKER_CONFIG, + options={CONF_VOLUME_STEP: VOLUME_STEP}, + source=SOURCE_IGNORE, + ) + entry.add_to_hass(hass) + + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": SOURCE_USER}, data=MOCK_SPEAKER_CONFIG + ) + assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY + + async def test_import_flow_minimum_fields( hass: HomeAssistantType, vizio_connect: pytest.fixture, @@ -679,6 +704,29 @@ async def test_import_error( assert len(vizio_log_list) == 1 +async def test_import_ignore( + hass: HomeAssistantType, + vizio_connect: pytest.fixture, + vizio_bypass_setup: pytest.fixture, +) -> None: + """Test import config flow doesn't throw an error when there's an existing ignored source.""" + entry = MockConfigEntry( + domain=DOMAIN, + data=MOCK_SPEAKER_CONFIG, + options={CONF_VOLUME_STEP: VOLUME_STEP}, + source=SOURCE_IGNORE, + ) + entry.add_to_hass(hass) + + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": SOURCE_IMPORT}, + data=vol.Schema(VIZIO_SCHEMA)(MOCK_SPEAKER_CONFIG), + ) + + assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY + + async def test_zeroconf_flow( hass: HomeAssistantType, vizio_connect: pytest.fixture, @@ -756,3 +804,26 @@ async def test_zeroconf_dupe_fail( # Flow should abort because device is already setup assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["reason"] == "already_in_progress" + + +async def test_zeroconf_ignore( + hass: HomeAssistantType, + vizio_connect: pytest.fixture, + vizio_bypass_setup: pytest.fixture, + vizio_guess_device_type: pytest.fixture, +) -> None: + """Test zeroconf discovery doesn't throw an error when there's an existing ignored source.""" + entry = MockConfigEntry( + domain=DOMAIN, + data=MOCK_SPEAKER_CONFIG, + options={CONF_VOLUME_STEP: VOLUME_STEP}, + source=SOURCE_IGNORE, + ) + entry.add_to_hass(hass) + + discovery_info = MOCK_ZEROCONF_SERVICE_INFO.copy() + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info + ) + + assert result["type"] == data_entry_flow.RESULT_TYPE_FORM From 0a1e33b7e142d318847443361a3d0b900d73816a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=B8yer=20Iversen?= Date: Thu, 16 Apr 2020 20:51:07 +0200 Subject: [PATCH 4/9] Upgrade broadlink lib to 0.13.1 (#34290) --- homeassistant/components/broadlink/manifest.json | 3 +-- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/broadlink/manifest.json b/homeassistant/components/broadlink/manifest.json index a179ca9c066..3c2c03384f3 100644 --- a/homeassistant/components/broadlink/manifest.json +++ b/homeassistant/components/broadlink/manifest.json @@ -2,7 +2,6 @@ "domain": "broadlink", "name": "Broadlink", "documentation": "https://www.home-assistant.io/integrations/broadlink", - "requirements": ["broadlink==0.13.0"], - "dependencies": [], + "requirements": ["broadlink==0.13.1"], "codeowners": ["@danielhiversen", "@felipediel"] } diff --git a/requirements_all.txt b/requirements_all.txt index 43a036b19f2..ca6bd795b82 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -355,7 +355,7 @@ boto3==1.9.252 bravia-tv==1.0.1 # homeassistant.components.broadlink -broadlink==0.13.0 +broadlink==0.13.1 # homeassistant.components.brother brother==0.1.11 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index f5318ffc955..c71b77b0008 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -137,7 +137,7 @@ bellows-homeassistant==0.15.2 bomradarloop==0.1.4 # homeassistant.components.broadlink -broadlink==0.13.0 +broadlink==0.13.1 # homeassistant.components.brother brother==0.1.11 From 81d006499ea29fd607bcf03a5d7f737c3709746c Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Thu, 16 Apr 2020 23:54:39 +0200 Subject: [PATCH 5/9] Pass an argument to kef.update_dsp for async_track_time_interval (#34310) --- homeassistant/components/kef/media_player.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/kef/media_player.py b/homeassistant/components/kef/media_player.py index 14e6e6b406f..d888b30a3b9 100644 --- a/homeassistant/components/kef/media_player.py +++ b/homeassistant/components/kef/media_player.py @@ -357,7 +357,7 @@ class KefMediaPlayer(MediaPlayerDevice): """Send next track command.""" await self._speaker.next_track() - async def update_dsp(self) -> None: + async def update_dsp(self, _=None) -> None: """Update the DSP settings.""" if self._speaker_type == "LS50" and self._state == STATE_OFF: # The LSX is able to respond when off the LS50 has to be on. From de440cf5790b0dd02e9d124814006291ee0a84ce Mon Sep 17 00:00:00 2001 From: Anders Melchiorsen Date: Fri, 17 Apr 2020 00:16:18 +0200 Subject: [PATCH 6/9] Fixes for Sonos media titles (#34311) --- .../components/sonos/media_player.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/sonos/media_player.py b/homeassistant/components/sonos/media_player.py index 13484e6901b..03f5999066d 100644 --- a/homeassistant/components/sonos/media_player.py +++ b/homeassistant/components/sonos/media_player.py @@ -419,7 +419,7 @@ class SonosEntity(MediaPlayerDevice): if self._status in ("PAUSED_PLAYBACK", "STOPPED",): # Sonos can consider itself "paused" but without having media loaded # (happens if playing Spotify and via Spotify app you pick another device to play on) - if self._media_title is None: + if self.media_title is None: return STATE_IDLE return STATE_PAUSED if self._status in ("PLAYING", "TRANSITIONING"): @@ -614,12 +614,19 @@ class SonosEntity(MediaPlayerDevice): except (TypeError, KeyError, AttributeError): pass - # Radios without tagging can have part of the radio URI as title. - # Non-playing radios will not have a current title. In these cases we - # try to use the radio name instead. + # Non-playing radios will not have a current title. Radios without tagging + # can have part of the radio URI as title. In these cases we try to use the + # radio name instead. try: - if self._media_title in self._uri or self.state != STATE_PLAYING: - self._media_title = variables["enqueued_transport_uri_meta_data"].title + uri_meta_data = variables["enqueued_transport_uri_meta_data"] + if isinstance( + uri_meta_data, pysonos.data_structures.DidlAudioBroadcast + ) and ( + self.state != STATE_PLAYING + or self.soco.is_radio_uri(self._media_title) + or self._media_title in self._uri + ): + self._media_title = uri_meta_data.title except (TypeError, KeyError, AttributeError): pass From 059df5e3e2b2366d8718956a84ab8f99b97989dd Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Thu, 16 Apr 2020 19:16:35 -0400 Subject: [PATCH 7/9] Abort vizio zeroconf config flow if unique ID is already configured (#34313) --- homeassistant/components/vizio/config_flow.py | 1 + tests/components/vizio/const.py | 1 + tests/components/vizio/test_config_flow.py | 26 +++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/homeassistant/components/vizio/config_flow.py b/homeassistant/components/vizio/config_flow.py index eac6df85f43..379f6c48ace 100644 --- a/homeassistant/components/vizio/config_flow.py +++ b/homeassistant/components/vizio/config_flow.py @@ -341,6 +341,7 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): await self.async_set_unique_id( unique_id=discovery_info[CONF_HOST].split(":")[0], raise_on_progress=True ) + self._abort_if_unique_id_configured() discovery_info[ CONF_HOST diff --git a/tests/components/vizio/const.py b/tests/components/vizio/const.py index f1ddc4abba6..56c3da3bc84 100644 --- a/tests/components/vizio/const.py +++ b/tests/components/vizio/const.py @@ -174,6 +174,7 @@ MOCK_INCLUDE_APPS = { CONF_INCLUDE_OR_EXCLUDE: CONF_INCLUDE.title(), CONF_APPS_TO_INCLUDE_OR_EXCLUDE: [CURRENT_APP], } + MOCK_INCLUDE_NO_APPS = { CONF_INCLUDE_OR_EXCLUDE: CONF_INCLUDE.title(), CONF_APPS_TO_INCLUDE_OR_EXCLUDE: [], diff --git a/tests/components/vizio/test_config_flow.py b/tests/components/vizio/test_config_flow.py index 3cb22a22541..0c057ba1a71 100644 --- a/tests/components/vizio/test_config_flow.py +++ b/tests/components/vizio/test_config_flow.py @@ -51,6 +51,7 @@ from .const import ( NAME2, UNIQUE_ID, VOLUME_STEP, + ZEROCONF_HOST, ) from tests.common import MockConfigEntry @@ -827,3 +828,28 @@ async def test_zeroconf_ignore( ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM + + +async def test_zeroconf_abort_when_ignored( + hass: HomeAssistantType, + vizio_connect: pytest.fixture, + vizio_bypass_setup: pytest.fixture, + vizio_guess_device_type: pytest.fixture, +) -> None: + """Test zeroconf discovery aborts when the same host has been ignored.""" + entry = MockConfigEntry( + domain=DOMAIN, + data=MOCK_SPEAKER_CONFIG, + options={CONF_VOLUME_STEP: VOLUME_STEP}, + source=SOURCE_IGNORE, + unique_id=ZEROCONF_HOST, + ) + entry.add_to_hass(hass) + + discovery_info = MOCK_ZEROCONF_SERVICE_INFO.copy() + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info + ) + + assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT + assert result["reason"] == "already_configured" From 317d08b6c1af82250207f82f93e311cb9a98db97 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 16 Apr 2020 16:44:14 -0700 Subject: [PATCH 8/9] Update Coordinator: Only schedule a refresh if listenerrs (#34317) --- homeassistant/helpers/update_coordinator.py | 3 ++- tests/helpers/test_update_coordinator.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/helpers/update_coordinator.py b/homeassistant/helpers/update_coordinator.py index b2b04816616..1f7e5326d6c 100644 --- a/homeassistant/helpers/update_coordinator.py +++ b/homeassistant/helpers/update_coordinator.py @@ -163,7 +163,8 @@ class DataUpdateCoordinator: self.name, monotonic() - start, ) - self._schedule_refresh() + if self._listeners: + self._schedule_refresh() for update_callback in self._listeners: update_callback() diff --git a/tests/helpers/test_update_coordinator.py b/tests/helpers/test_update_coordinator.py index c17c79ccbc8..cb53bc5e04e 100644 --- a/tests/helpers/test_update_coordinator.py +++ b/tests/helpers/test_update_coordinator.py @@ -40,6 +40,8 @@ async def test_async_refresh(crd): await crd.async_refresh() assert crd.data == 1 assert crd.last_update_success is True + # Make sure we didn't schedule a refresh because we have 0 listeners + assert crd._unsub_refresh is None updates = [] From 334fecdf6f86a06cfdd70623def9644784661389 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 16 Apr 2020 17:46:39 -0700 Subject: [PATCH 9/9] Bumped version to 0.108.6 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index a1998252008..33e0c685d26 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -1,7 +1,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 108 -PATCH_VERSION = "5" +PATCH_VERSION = "6" __short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}" __version__ = f"{__short_version__}.{PATCH_VERSION}" REQUIRED_PYTHON_VER = (3, 7, 0)