mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
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
This commit is contained in:
parent
a7325ebe1f
commit
72419a1afe
@ -59,8 +59,9 @@ def setup(hass, config):
|
|||||||
_LOGGER.debug("Ecobot devices: %s", devices)
|
_LOGGER.debug("Ecobot devices: %s", devices)
|
||||||
|
|
||||||
for device in devices:
|
for device in devices:
|
||||||
_LOGGER.info("Discovered Ecovacs device on account: %s",
|
_LOGGER.info(
|
||||||
device['nick'])
|
"Discovered Ecovacs device on account: %s with nickname %s",
|
||||||
|
device['did'], device['nick'])
|
||||||
vacbot = VacBot(ecovacs_api.uid,
|
vacbot = VacBot(ecovacs_api.uid,
|
||||||
ecovacs_api.REALM,
|
ecovacs_api.REALM,
|
||||||
ecovacs_api.resource,
|
ecovacs_api.resource,
|
||||||
@ -74,7 +75,7 @@ def setup(hass, config):
|
|||||||
"""Shut down open connections to Ecovacs XMPP server."""
|
"""Shut down open connections to Ecovacs XMPP server."""
|
||||||
for device in hass.data[ECOVACS_DEVICES]:
|
for device in hass.data[ECOVACS_DEVICES]:
|
||||||
_LOGGER.info("Shutting down connection to Ecovacs device %s",
|
_LOGGER.info("Shutting down connection to Ecovacs device %s",
|
||||||
device.vacuum['nick'])
|
device.vacuum['did'])
|
||||||
device.disconnect()
|
device.disconnect()
|
||||||
|
|
||||||
# Listen for HA stop to disconnect.
|
# Listen for HA stop to disconnect.
|
||||||
|
@ -43,9 +43,9 @@ class EcovacsVacuum(VacuumDevice):
|
|||||||
"""Initialize the Ecovacs Vacuum."""
|
"""Initialize the Ecovacs Vacuum."""
|
||||||
self.device = device
|
self.device = device
|
||||||
self.device.connect_and_wait_until_ready()
|
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'])
|
self._name = '{}'.format(self.device.vacuum['nick'])
|
||||||
except KeyError:
|
else:
|
||||||
# In case there is no nickname defined, use the device id
|
# In case there is no nickname defined, use the device id
|
||||||
self._name = '{}'.format(self.device.vacuum['did'])
|
self._name = '{}'.format(self.device.vacuum['did'])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user