From 97e98674fa9ba3c668e11b41c45708d9b2aaa8a4 Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Wed, 24 Jan 2024 10:27:08 +0100 Subject: [PATCH] Do not crash on missing geolocation If 'has_set_location_info' is false, the geolocation is missing. --- kasa/tapo/tapodevice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kasa/tapo/tapodevice.py b/kasa/tapo/tapodevice.py index 156a61d1a..86967b69d 100644 --- a/kasa/tapo/tapodevice.py +++ b/kasa/tapo/tapodevice.py @@ -147,8 +147,8 @@ def hw_info(self) -> Dict: def location(self) -> Dict: """Return the device location.""" loc = { - "latitude": cast(float, self._info.get("latitude")) / 10_000, - "longitude": cast(float, self._info.get("longitude")) / 10_000, + "latitude": cast(float, self._info.get("latitude", 0)) / 10_000, + "longitude": cast(float, self._info.get("longitude", 0)) / 10_000, } return loc