Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ICAO 24-bit address to the OpenSky sensor events #66114

Merged
merged 1 commit into from Feb 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion homeassistant/components/opensky/sensor.py
Expand Up @@ -26,6 +26,7 @@

CONF_ALTITUDE = "altitude"

ATTR_ICAO24 = "icao24"
ATTR_CALLSIGN = "callsign"
ATTR_ALTITUDE = "altitude"
ATTR_ON_GROUND = "on_ground"
Expand All @@ -45,7 +46,7 @@
)
OPENSKY_API_URL = "https://opensky-network.org/api/states/all"
OPENSKY_API_FIELDS = [
"icao24",
ATTR_ICAO24,
ATTR_CALLSIGN,
"origin_country",
"time_position",
Expand Down Expand Up @@ -128,18 +129,21 @@ def _handle_boundary(self, flights, event, metadata):
altitude = metadata[flight].get(ATTR_ALTITUDE)
longitude = metadata[flight].get(ATTR_LONGITUDE)
latitude = metadata[flight].get(ATTR_LATITUDE)
icao24 = metadata[flight].get(ATTR_ICAO24)
else:
# Assume Flight has landed if missing.
altitude = 0
longitude = None
latitude = None
icao24 = None

data = {
ATTR_CALLSIGN: flight,
ATTR_ALTITUDE: altitude,
ATTR_SENSOR: self._name,
ATTR_LONGITUDE: longitude,
ATTR_LATITUDE: latitude,
ATTR_ICAO24: icao24,
}
self._hass.bus.fire(event, data)

Expand Down