From 0cdea28e2a1770b33d8eb79e6b226cdfcda40076 Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Sat, 1 Jun 2019 00:51:55 +0200 Subject: [PATCH] Don't allow more than one config flow per discovered Axis device (#24230) --- homeassistant/components/axis/config_flow.py | 7 +++++++ homeassistant/components/axis/strings.json | 1 + 2 files changed, 8 insertions(+) diff --git a/homeassistant/components/axis/config_flow.py b/homeassistant/components/axis/config_flow.py index fc2051e4925..2aa5c4de16e 100644 --- a/homeassistant/components/axis/config_flow.py +++ b/homeassistant/components/axis/config_flow.py @@ -155,6 +155,13 @@ class AxisFlowHandler(config_entries.ConfigFlow): return self.async_abort(reason='link_local_address') serialnumber = discovery_info['properties']['macaddress'] + # pylint: disable=unsupported-assignment-operation + self.context['macaddress'] = serialnumber + + if any(serialnumber == flow['context']['macaddress'] + for flow in self._async_in_progress()): + return self.async_abort(reason='already_in_progress') + device_entries = configured_devices(self.hass) if serialnumber in device_entries: diff --git a/homeassistant/components/axis/strings.json b/homeassistant/components/axis/strings.json index 3c528dfbb16..ebefbecf311 100644 --- a/homeassistant/components/axis/strings.json +++ b/homeassistant/components/axis/strings.json @@ -14,6 +14,7 @@ }, "error": { "already_configured": "Device is already configured", + "already_in_progress": "Config flow for device is already in progress.", "device_unavailable": "Device is not available", "faulty_credentials": "Bad user credentials" },