-
Notifications
You must be signed in to change notification settings - Fork 0
fix: remove invalid response key from services.yaml to pass hassfest
#35
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
44ca28a
Initial plan
Copilot bbcf07b
fix: resolve sensor unknown state and move formatted_events to servic…
Copilot 4757ae8
docs: update README.md for v1.2.1 changes
Copilot e5f6738
fix: remove invalid response key from services.yaml to pass hassfest
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| """Helper utilities for USGS Quakes integration.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| from datetime import datetime, timezone | ||
| from typing import Any | ||
|
|
||
| from homeassistant.util.dt import as_local | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def parse_event_time(time_val: Any) -> datetime: | ||
| """Parse an event time value that may be a datetime object or an ISO string.""" | ||
| if isinstance(time_val, datetime): | ||
| return time_val | ||
| t_str = str(time_val) if time_val is not None else "" | ||
| if t_str.endswith("Z"): | ||
| t_str = t_str.replace("Z", "+00:00") | ||
| try: | ||
| return datetime.fromisoformat(t_str) | ||
| except ValueError: | ||
| _LOGGER.debug("Could not parse event time: %s", time_val) | ||
| return datetime.min | ||
|
|
||
|
|
||
| def format_event(e: dict[str, Any]) -> str: | ||
| """Return a human-readable string for a single earthquake event.""" | ||
| t = e.get("time") | ||
| try: | ||
| if isinstance(t, datetime): | ||
| dt = t if t.tzinfo else t.replace(tzinfo=timezone.utc) | ||
| else: | ||
| dt = datetime.fromisoformat(str(t).replace("Z", "+00:00")) | ||
| dt_str = as_local(dt).strftime("%Y-%m-%d %H:%M:%S") | ||
| except (ValueError, AttributeError): | ||
| _LOGGER.debug("Could not format event time: %s", t) | ||
| dt_str = str(t) | ||
|
|
||
| coords = e.get("coordinates") or [None, None] | ||
| lat = coords[0] if len(coords) > 0 else None | ||
| lon = coords[1] if len(coords) > 1 else None | ||
| maps_url = ( | ||
| f"https://www.google.com/maps?q={lat},{lon}" | ||
| if lat is not None and lon is not None | ||
| else "N/A" | ||
| ) | ||
|
|
||
| return ( | ||
| f"{e.get('title', 'N/A')}\n" | ||
| f"Lugar: {e.get('place', 'N/A')}\n" | ||
| f"Magnitud: {e.get('magnitude', 'N/A')} Mw\n" | ||
| f"Fecha/Hora: {dt_str}\n" | ||
| f"Localización: {maps_url}" | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,5 +13,5 @@ | |
| "aio-geojson-usgs-earthquakes==0.3", | ||
| "aio-geojson-client==0.12" | ||
| ], | ||
| "version": "1.2.0" | ||
| "version": "1.2.1" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Avoid unnecessarily wrapping
parse_event_timein a lambda. More details.