From 7f7a0003c7d9ef2ca9b35e30fa84c88a2356d089 Mon Sep 17 00:00:00 2001 From: Rob Bierbooms Date: Fri, 4 Sep 2020 20:56:22 +0200 Subject: [PATCH] Address review comments on dsmr update to ConfigEntry (#39662) --- homeassistant/components/dsmr/config_flow.py | 4 +++- homeassistant/components/dsmr/sensor.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/dsmr/config_flow.py b/homeassistant/components/dsmr/config_flow.py index ecf93177334..d3aa770ff60 100644 --- a/homeassistant/components/dsmr/config_flow.py +++ b/homeassistant/components/dsmr/config_flow.py @@ -24,7 +24,7 @@ class DSMRFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): reload_on_update: bool = True, ): """Test if host and port are already configured.""" - for entry in self.hass.config_entries.async_entries(DOMAIN): + for entry in self._async_current_entries(): if entry.data.get(CONF_HOST) == host and entry.data[CONF_PORT] == port: if updates is not None: changed = self.hass.config_entries.async_update_entry( @@ -44,6 +44,8 @@ class DSMRFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ) return self.async_abort(reason="already_configured") + return None + async def async_step_import(self, import_config=None): """Handle the initial step.""" host = import_config.get(CONF_HOST) diff --git a/homeassistant/components/dsmr/sensor.py b/homeassistant/components/dsmr/sensor.py index 4298afe3cf6..c98dc316d0d 100644 --- a/homeassistant/components/dsmr/sensor.py +++ b/homeassistant/components/dsmr/sensor.py @@ -200,7 +200,7 @@ async def async_setup_entry( return # Can't be hass.async_add_job because job runs forever - task = hass.loop.create_task(connect_and_reconnect()) + task = asyncio.create_task(connect_and_reconnect()) # Save the task to be able to cancel it when unloading hass.data[DOMAIN][entry.entry_id][DATA_TASK] = task