From 70bd998d7cfe2f963c35b463756580441d0dd61c Mon Sep 17 00:00:00 2001 From: Greg Date: Mon, 14 Dec 2020 13:51:28 -0800 Subject: [PATCH 01/10] Bump envoy_reader version to 0.17.3 (#44205) * Bump envoy_reader version to 0.17.0rc0 * Fixing version number --- homeassistant/components/enphase_envoy/manifest.json | 2 +- requirements_all.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/enphase_envoy/manifest.json b/homeassistant/components/enphase_envoy/manifest.json index e6ab8dbf6a9230..b339013a69f84a 100644 --- a/homeassistant/components/enphase_envoy/manifest.json +++ b/homeassistant/components/enphase_envoy/manifest.json @@ -2,7 +2,7 @@ "domain": "enphase_envoy", "name": "Enphase Envoy", "documentation": "https://www.home-assistant.io/integrations/enphase_envoy", - "requirements": ["envoy_reader==0.17.0"], + "requirements": ["envoy_reader==0.17.3"], "codeowners": [ "@gtdiehl" ] diff --git a/requirements_all.txt b/requirements_all.txt index 858b747b2ae2e3..1f417c7a40244c 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -559,7 +559,7 @@ env_canada==0.2.4 # envirophat==0.0.6 # homeassistant.components.enphase_envoy -envoy_reader==0.17.0 +envoy_reader==0.17.3 # homeassistant.components.season ephem==3.7.7.0 From 150ce05e2667aaabbf6eae6b41965412bc03eb4e Mon Sep 17 00:00:00 2001 From: Rob Bierbooms Date: Tue, 15 Dec 2020 04:45:24 +0100 Subject: [PATCH 02/10] Bump dsmr-parser to 0.25 (#44223) * Bump version in manifest * Update requirements_all.txt * Update requirements_test_all.txt --- homeassistant/components/dsmr/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/dsmr/manifest.json b/homeassistant/components/dsmr/manifest.json index fdbba4212f6c6b..c3f6aa4dea33ad 100644 --- a/homeassistant/components/dsmr/manifest.json +++ b/homeassistant/components/dsmr/manifest.json @@ -2,7 +2,7 @@ "domain": "dsmr", "name": "DSMR Slimme Meter", "documentation": "https://www.home-assistant.io/integrations/dsmr", - "requirements": ["dsmr_parser==0.23"], + "requirements": ["dsmr_parser==0.25"], "codeowners": ["@Robbie1221"], "config_flow": false } diff --git a/requirements_all.txt b/requirements_all.txt index 1f417c7a40244c..7e37bc0a8e695c 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -508,7 +508,7 @@ doorbirdpy==2.1.0 dovado==0.4.1 # homeassistant.components.dsmr -dsmr_parser==0.23 +dsmr_parser==0.25 # homeassistant.components.dwd_weather_warnings dwdwfsapi==1.0.3 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 9dc1bd8d86096a..fd6dc5c612a0d2 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -269,7 +269,7 @@ distro==1.5.0 doorbirdpy==2.1.0 # homeassistant.components.dsmr -dsmr_parser==0.23 +dsmr_parser==0.25 # homeassistant.components.dynalite dynalite_devices==0.1.46 From 43ef5bab182b96a7f04a9768f77504a725030c39 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Mon, 14 Dec 2020 13:03:25 -0700 Subject: [PATCH 03/10] Fix unhandled KeyError in Recollect Waste (#44224) --- homeassistant/components/recollect_waste/manifest.json | 2 +- homeassistant/components/recollect_waste/sensor.py | 6 ++++-- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/recollect_waste/manifest.json b/homeassistant/components/recollect_waste/manifest.json index 4e6b71d59b7a4e..dc8a85ce2aacd2 100644 --- a/homeassistant/components/recollect_waste/manifest.json +++ b/homeassistant/components/recollect_waste/manifest.json @@ -4,7 +4,7 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/recollect_waste", "requirements": [ - "aiorecollect==0.2.2" + "aiorecollect==1.0.1" ], "codeowners": [ "@bachya" diff --git a/homeassistant/components/recollect_waste/sensor.py b/homeassistant/components/recollect_waste/sensor.py index 7ce75b1e3fa482..53304c932185d3 100644 --- a/homeassistant/components/recollect_waste/sensor.py +++ b/homeassistant/components/recollect_waste/sensor.py @@ -120,9 +120,11 @@ def update_from_latest_data(self) -> None: self._state = pickup_event.date self._attributes.update( { - ATTR_PICKUP_TYPES: pickup_event.pickup_types, + ATTR_PICKUP_TYPES: [t.name for t in pickup_event.pickup_types], ATTR_AREA_NAME: pickup_event.area_name, - ATTR_NEXT_PICKUP_TYPES: next_pickup_event.pickup_types, + ATTR_NEXT_PICKUP_TYPES: [ + t.name for t in next_pickup_event.pickup_types + ], ATTR_NEXT_PICKUP_DATE: next_date, } ) diff --git a/requirements_all.txt b/requirements_all.txt index 7e37bc0a8e695c..10746f93d632cf 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -215,7 +215,7 @@ aiopvpc==2.0.2 aiopylgtv==0.3.3 # homeassistant.components.recollect_waste -aiorecollect==0.2.2 +aiorecollect==1.0.1 # homeassistant.components.shelly aioshelly==0.5.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index fd6dc5c612a0d2..830f2cd67d4abb 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -131,7 +131,7 @@ aiopvpc==2.0.2 aiopylgtv==0.3.3 # homeassistant.components.recollect_waste -aiorecollect==0.2.2 +aiorecollect==1.0.1 # homeassistant.components.shelly aioshelly==0.5.1 From 07df3b95654711883b273ce649b9cb6bd20f7c1a Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Tue, 15 Dec 2020 17:23:00 +0100 Subject: [PATCH 04/10] Bump hatasmota to 0.1.6 (#44226) --- homeassistant/components/tasmota/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/tasmota/manifest.json b/homeassistant/components/tasmota/manifest.json index a4c6f77fc131c4..5b298d44ce0a2c 100644 --- a/homeassistant/components/tasmota/manifest.json +++ b/homeassistant/components/tasmota/manifest.json @@ -3,7 +3,7 @@ "name": "Tasmota (beta)", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/tasmota", - "requirements": ["hatasmota==0.1.4"], + "requirements": ["hatasmota==0.1.6"], "dependencies": ["mqtt"], "mqtt": ["tasmota/discovery/#"], "codeowners": ["@emontnemery"] diff --git a/requirements_all.txt b/requirements_all.txt index 10746f93d632cf..3b1fa3f76e65dd 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -738,7 +738,7 @@ hass-nabucasa==0.39.0 hass_splunk==0.1.1 # homeassistant.components.tasmota -hatasmota==0.1.4 +hatasmota==0.1.6 # homeassistant.components.jewish_calendar hdate==0.9.12 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 830f2cd67d4abb..e8d3dfedfc8153 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -376,7 +376,7 @@ hangups==0.4.11 hass-nabucasa==0.39.0 # homeassistant.components.tasmota -hatasmota==0.1.4 +hatasmota==0.1.6 # homeassistant.components.jewish_calendar hdate==0.9.12 From 3752fa3123e755320608bd2ae9c41a8e30515d76 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Wed, 16 Dec 2020 11:00:22 +0100 Subject: [PATCH 05/10] Remove Home Assistant Cast user when removing entry (#44228) * Remove Home Assistant Cast user when removing entry * Fix test * Fix test --- homeassistant/components/cast/__init__.py | 5 ++++ .../components/cast/home_assistant_cast.py | 11 +++++++ .../cast/test_home_assistant_cast.py | 30 +++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/homeassistant/components/cast/__init__.py b/homeassistant/components/cast/__init__.py index 4dfb58ef3b7d6e..49cec207764477 100644 --- a/homeassistant/components/cast/__init__.py +++ b/homeassistant/components/cast/__init__.py @@ -29,3 +29,8 @@ async def async_setup_entry(hass, entry: config_entries.ConfigEntry): hass.config_entries.async_forward_entry_setup(entry, "media_player") ) return True + + +async def async_remove_entry(hass, entry): + """Remove Home Assistant Cast user.""" + await home_assistant_cast.async_remove_user(hass, entry) diff --git a/homeassistant/components/cast/home_assistant_cast.py b/homeassistant/components/cast/home_assistant_cast.py index 28672ef409c17b..3edc1ce2cde59d 100644 --- a/homeassistant/components/cast/home_assistant_cast.py +++ b/homeassistant/components/cast/home_assistant_cast.py @@ -72,3 +72,14 @@ async def handle_show_view(call: core.ServiceCall): } ), ) + + +async def async_remove_user( + hass: core.HomeAssistant, entry: config_entries.ConfigEntry +): + """Remove Home Assistant Cast user.""" + user_id: Optional[str] = entry.data.get("user_id") + + if user_id is not None: + user = await hass.auth.async_get_user(user_id) + await hass.auth.async_remove_user(user) diff --git a/tests/components/cast/test_home_assistant_cast.py b/tests/components/cast/test_home_assistant_cast.py index 2fff760bb7055e..8ddb6e82eda48d 100644 --- a/tests/components/cast/test_home_assistant_cast.py +++ b/tests/components/cast/test_home_assistant_cast.py @@ -1,5 +1,6 @@ """Test Home Assistant Cast.""" +from homeassistant import config_entries from homeassistant.components.cast import home_assistant_cast from homeassistant.config import async_process_ha_core_config @@ -86,3 +87,32 @@ async def test_use_cloud_url(hass, mock_zeroconf): assert len(calls) == 1 controller = calls[0][0] assert controller.hass_url == "https://something.nabu.casa" + + +async def test_remove_entry(hass, mock_zeroconf): + """Test removing config entry removes user.""" + entry = MockConfigEntry( + connection_class=config_entries.CONN_CLASS_LOCAL_PUSH, + data={}, + domain="cast", + title="Google Cast", + ) + + entry.add_to_hass(hass) + + with patch( + "homeassistant.components.cast.media_player._async_setup_platform" + ), patch( + "pychromecast.discovery.discover_chromecasts", return_value=(True, None) + ), patch( + "pychromecast.discovery.stop_discovery" + ): + assert await hass.config_entries.async_setup(entry.entry_id) + await hass.async_block_till_done() + assert "cast" in hass.config.components + + user_id = entry.data.get("user_id") + assert await hass.auth.async_get_user(user_id) + + assert await hass.config_entries.async_remove(entry.entry_id) + assert not await hass.auth.async_get_user(user_id) From 3ab0b63540e0aebf836947ab5196b1cf6b0aaf32 Mon Sep 17 00:00:00 2001 From: "David F. Mulcahey" Date: Tue, 15 Dec 2020 10:44:28 -0500 Subject: [PATCH 06/10] Default smartenergy multiplier and divisor (#44257) --- homeassistant/components/zha/core/channels/smartenergy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/zha/core/channels/smartenergy.py b/homeassistant/components/zha/core/channels/smartenergy.py index 792b94132942c6..87c22b160f44d1 100644 --- a/homeassistant/components/zha/core/channels/smartenergy.py +++ b/homeassistant/components/zha/core/channels/smartenergy.py @@ -89,12 +89,12 @@ def __init__( @property def divisor(self) -> int: """Return divisor for the value.""" - return self.cluster.get("divisor") + return self.cluster.get("divisor") or 1 @property def multiplier(self) -> int: """Return multiplier for the value.""" - return self.cluster.get("multiplier") + return self.cluster.get("multiplier") or 1 async def async_configure(self) -> None: """Configure channel.""" From 3a41878a8c0f758d22fa364d7535fbea53b57a31 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 16 Dec 2020 11:18:50 +0100 Subject: [PATCH 07/10] Fix setting timestamp on input_datetime (#44274) --- .../components/input_datetime/__init__.py | 8 ++---- tests/components/input_datetime/test_init.py | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/input_datetime/__init__.py b/homeassistant/components/input_datetime/__init__.py index aa1f0b8814a1d6..195e4c2242ebe8 100644 --- a/homeassistant/components/input_datetime/__init__.py +++ b/homeassistant/components/input_datetime/__init__.py @@ -365,9 +365,7 @@ def unique_id(self) -> typing.Optional[str]: def async_set_datetime(self, date=None, time=None, datetime=None, timestamp=None): """Set a new date / time.""" if timestamp: - datetime = dt_util.as_local(dt_util.utc_from_timestamp(timestamp)).replace( - tzinfo=None - ) + datetime = dt_util.as_local(dt_util.utc_from_timestamp(timestamp)) if datetime: date = datetime.date() @@ -388,8 +386,8 @@ def async_set_datetime(self, date=None, time=None, datetime=None, timestamp=None if not time: time = self._current_datetime.time() - self._current_datetime = py_datetime.datetime.combine(date, time).replace( - tzinfo=dt_util.DEFAULT_TIME_ZONE + self._current_datetime = dt_util.DEFAULT_TIME_ZONE.localize( + py_datetime.datetime.combine(date, time) ) self.async_write_ha_state() diff --git a/tests/components/input_datetime/test_init.py b/tests/components/input_datetime/test_init.py index d40a88e3f436e6..a336ef82363c0c 100644 --- a/tests/components/input_datetime/test_init.py +++ b/tests/components/input_datetime/test_init.py @@ -697,6 +697,15 @@ async def test_timestamp(hass): ).strftime(FMT_DATETIME) == "2020-12-13 10:00:00" ) + # Use datetime.datetime.fromtimestamp + assert ( + dt_util.as_local( + datetime.datetime.fromtimestamp( + state_without_tz.attributes[ATTR_TIMESTAMP] + ) + ).strftime(FMT_DATETIME) + == "2020-12-13 10:00:00" + ) # Test initial time sets timestamp correctly. state_time = hass.states.get("input_datetime.test_time_initial") @@ -704,5 +713,24 @@ async def test_timestamp(hass): assert state_time.state == "10:00:00" assert state_time.attributes[ATTR_TIMESTAMP] == 10 * 60 * 60 + # Test that setting the timestamp of an entity works. + await hass.services.async_call( + DOMAIN, + "set_datetime", + { + ATTR_ENTITY_ID: "input_datetime.test_datetime_initial_with_tz", + ATTR_TIMESTAMP: state_without_tz.attributes[ATTR_TIMESTAMP], + }, + blocking=True, + ) + state_with_tz_updated = hass.states.get( + "input_datetime.test_datetime_initial_with_tz" + ) + assert state_with_tz_updated.state == "2020-12-13 10:00:00" + assert ( + state_with_tz_updated.attributes[ATTR_TIMESTAMP] + == state_without_tz.attributes[ATTR_TIMESTAMP] + ) + finally: dt_util.set_default_time_zone(ORIG_TIMEZONE) From 3a82aecd38ab1d86fb2ade556b6db3cd894a7980 Mon Sep 17 00:00:00 2001 From: Shay Levy Date: Wed, 16 Dec 2020 22:28:59 +0200 Subject: [PATCH 08/10] Fix Shelly devices missing properties field (#44279) --- .../components/shelly/config_flow.py | 8 +---- tests/components/shelly/test_config_flow.py | 30 +------------------ 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/homeassistant/components/shelly/config_flow.py b/homeassistant/components/shelly/config_flow.py index 88e01f04bc5df7..e23e9561c776e6 100644 --- a/homeassistant/components/shelly/config_flow.py +++ b/homeassistant/components/shelly/config_flow.py @@ -27,12 +27,6 @@ HTTP_CONNECT_ERRORS = (asyncio.TimeoutError, aiohttp.ClientError) -def _remove_prefix(shelly_str): - if shelly_str.startswith("shellyswitch"): - return shelly_str[6:] - return shelly_str - - async def validate_input(hass: core.HomeAssistant, host, data): """Validate the user input allows us to connect. @@ -159,7 +153,7 @@ async def async_step_zeroconf(self, zeroconf_info): self.host = zeroconf_info["host"] # pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167 self.context["title_placeholders"] = { - "name": _remove_prefix(zeroconf_info["properties"]["id"]) + "name": zeroconf_info.get("name", "").split(".")[0] } return await self.async_step_confirm_discovery() diff --git a/tests/components/shelly/test_config_flow.py b/tests/components/shelly/test_config_flow.py index 1796847bd74e24..fe6a567e32e615 100644 --- a/tests/components/shelly/test_config_flow.py +++ b/tests/components/shelly/test_config_flow.py @@ -20,11 +20,6 @@ "name": "shelly1pm-12345", "properties": {"id": "shelly1pm-12345"}, } -SWITCH25_DISCOVERY_INFO = { - "host": "1.1.1.1", - "name": "shellyswitch25-12345", - "properties": {"id": "shellyswitch25-12345"}, -} async def test_form(hass): @@ -67,7 +62,7 @@ async def test_form(hass): assert len(mock_setup_entry.mock_calls) == 1 -async def test_title_without_name_and_prefix(hass): +async def test_title_without_name(hass): """Test we set the title to the hostname when the device doesn't have a name.""" await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( @@ -330,29 +325,6 @@ async def test_zeroconf(hass): assert len(mock_setup_entry.mock_calls) == 1 -async def test_zeroconf_with_switch_prefix(hass): - """Test we get remove shelly from the prefix.""" - await setup.async_setup_component(hass, "persistent_notification", {}) - - with patch( - "aioshelly.get_info", - return_value={"mac": "test-mac", "type": "SHSW-1", "auth": False}, - ): - result = await hass.config_entries.flow.async_init( - DOMAIN, - data=SWITCH25_DISCOVERY_INFO, - context={"source": config_entries.SOURCE_ZEROCONF}, - ) - assert result["type"] == "form" - assert result["errors"] == {} - context = next( - flow["context"] - for flow in hass.config_entries.flow.async_progress() - if flow["flow_id"] == result["flow_id"] - ) - assert context["title_placeholders"]["name"] == "switch25-12345" - - @pytest.mark.parametrize( "error", [(asyncio.TimeoutError, "cannot_connect"), (ValueError, "unknown")] ) From ff9e1ddeed8d6248db16d8fa45993ac5ad3a0310 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 16 Dec 2020 20:29:55 +0000 Subject: [PATCH 09/10] Bumped version to 2020.12.1 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 1e7d243b9ad108..582648e8d324a0 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -1,7 +1,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 2020 MINOR_VERSION = 12 -PATCH_VERSION = "0" +PATCH_VERSION = "1" __short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}" __version__ = f"{__short_version__}.{PATCH_VERSION}" REQUIRED_PYTHON_VER = (3, 7, 1) From ac62028c196bff5665510d13c2b1dbddb5fc8eaa Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 16 Dec 2020 20:55:22 +0000 Subject: [PATCH 10/10] Fix account link test --- tests/components/cloud/test_account_link.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/components/cloud/test_account_link.py b/tests/components/cloud/test_account_link.py index ce310001b35a1b..1580969b0a5392 100644 --- a/tests/components/cloud/test_account_link.py +++ b/tests/components/cloud/test_account_link.py @@ -44,7 +44,7 @@ async def test_setup_provide_implementation(hass): "homeassistant.components.cloud.account_link._get_services", return_value=[ {"service": "test", "min_version": "0.1.0"}, - {"service": "too_new", "min_version": "100.0.0"}, + {"service": "too_new", "min_version": "1000000.0.0"}, ], ): assert (