From 2d6d6ba90e5e2f179a07c4ecd7de1744e86a8025 Mon Sep 17 00:00:00 2001 From: Antonio Larrosa Date: Thu, 17 Oct 2019 11:29:08 +0200 Subject: [PATCH] Forget auth token when going offline so we can reconnect (#26630) When an amcrest camera was unplugged and then plugged again it was impossible to reconnect to it, since the old auth token was reused while we need to use a new one. In fact, the method that is called every minute to check the camera availability is going to fail always since we're reusing an old token. By forgetting the token (setting it to None) when going offline, we ensure that we'll regenerate it in the next commands thus allowing to reconnect to the camera when it comes back online. --- homeassistant/components/amcrest/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/homeassistant/components/amcrest/__init__.py b/homeassistant/components/amcrest/__init__.py index f915872abf0..d49104a0b26 100644 --- a/homeassistant/components/amcrest/__init__.py +++ b/homeassistant/components/amcrest/__init__.py @@ -167,6 +167,8 @@ class AmcrestChecker(Http): offline = not self.available if offline and was_online: _LOGGER.error("%s camera offline: Too many errors", self._wrap_name) + with self._token_lock: + self._token = None dispatcher_send( self._hass, service_signal(SERVICE_UPDATE, self._wrap_name) )