-
-
Notifications
You must be signed in to change notification settings - Fork 95
Temperature, catch bad latitude/longitude #3339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,6 +76,13 @@ def get_coordinates(self): | |
| if longitude is None: | ||
| longitude = self.get_state_wrapper("zone.home", attribute="longitude") | ||
|
|
||
| try: | ||
| latitude = float(latitude) | ||
| longitude = float(longitude) | ||
| except (TypeError, ValueError): | ||
| self.log("Warn: TemperatureAPI: Invalid latitude or longitude values: latitude {}, longitude {}".format(latitude, longitude)) | ||
|
Comment on lines
+79
to
+83
|
||
| return None, None | ||
|
|
||
| if latitude is not None and longitude is not None: | ||
| self.log("TemperatureAPI: Using coordinates latitude {}, longitude {}".format(dp1(latitude), dp1(longitude))) | ||
| return latitude, longitude | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because latitude/longitude are always either successfully converted to floats or the function returns in the except block, the later
if latitude is not None and longitude is not None:check becomes redundant and theelsebranch is effectively unreachable. Consider handling the "missing" case before conversion (for clearer logging) or simplifying the control flow after the conversion.