From 72419a1afe5aa09c8e5e5d79c32d9c09a7af4241 Mon Sep 17 00:00:00 2001 From: Greg Laabs <OverloadUT@gmail.com> Date: Mon, 17 Sep 2018 23:30:20 -0700 Subject: [PATCH] Fix Ecovacs vacuums showing "None" for name (#16654) Was previously checking for a missing key, when should have been checking for the value being None --- homeassistant/components/ecovacs.py | 7 ++++--- homeassistant/components/vacuum/ecovacs.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/ecovacs.py b/homeassistant/components/ecovacs.py index 2e51b048d15..53761a1013f 100644 --- a/homeassistant/components/ecovacs.py +++ b/homeassistant/components/ecovacs.py @@ -59,8 +59,9 @@ def setup(hass, config): _LOGGER.debug("Ecobot devices: %s", devices) for device in devices: - _LOGGER.info("Discovered Ecovacs device on account: %s", - device['nick']) + _LOGGER.info( + "Discovered Ecovacs device on account: %s with nickname %s", + device['did'], device['nick']) vacbot = VacBot(ecovacs_api.uid, ecovacs_api.REALM, ecovacs_api.resource, @@ -74,7 +75,7 @@ def setup(hass, config): """Shut down open connections to Ecovacs XMPP server.""" for device in hass.data[ECOVACS_DEVICES]: _LOGGER.info("Shutting down connection to Ecovacs device %s", - device.vacuum['nick']) + device.vacuum['did']) device.disconnect() # Listen for HA stop to disconnect. diff --git a/homeassistant/components/vacuum/ecovacs.py b/homeassistant/components/vacuum/ecovacs.py index b92ae598f80..927362ac9db 100644 --- a/homeassistant/components/vacuum/ecovacs.py +++ b/homeassistant/components/vacuum/ecovacs.py @@ -43,9 +43,9 @@ class EcovacsVacuum(VacuumDevice): """Initialize the Ecovacs Vacuum.""" self.device = device self.device.connect_and_wait_until_ready() - try: + if self.device.vacuum.get('nick', None) is not None: self._name = '{}'.format(self.device.vacuum['nick']) - except KeyError: + else: # In case there is no nickname defined, use the device id self._name = '{}'.format(self.device.vacuum['did']) -- GitLab