Skip to content

Commit

Permalink
Move OpenSky constants to separate const file (#97013)
Browse files Browse the repository at this point in the history
  • Loading branch information
joostlek authored Jul 21, 2023
1 parent 7d173bf commit 9954208
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 32 deletions.
15 changes: 15 additions & 0 deletions homeassistant/components/opensky/const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""OpenSky constants."""
DEFAULT_NAME = "OpenSky"
DOMAIN = "opensky"

CONF_ALTITUDE = "altitude"
ATTR_ICAO24 = "icao24"
ATTR_CALLSIGN = "callsign"
ATTR_ALTITUDE = "altitude"
ATTR_ON_GROUND = "on_ground"
ATTR_SENSOR = "sensor"
ATTR_STATES = "states"
DEFAULT_ALTITUDE = 0

EVENT_OPENSKY_ENTRY = f"{DOMAIN}_entry"
EVENT_OPENSKY_EXIT = f"{DOMAIN}_exit"
43 changes: 11 additions & 32 deletions homeassistant/components/opensky/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,21 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType

CONF_ALTITUDE = "altitude"

ATTR_ICAO24 = "icao24"
ATTR_CALLSIGN = "callsign"
ATTR_ALTITUDE = "altitude"
ATTR_ON_GROUND = "on_ground"
ATTR_SENSOR = "sensor"
ATTR_STATES = "states"

DOMAIN = "opensky"

DEFAULT_ALTITUDE = 0
from .const import (
ATTR_ALTITUDE,
ATTR_CALLSIGN,
ATTR_ICAO24,
ATTR_SENSOR,
CONF_ALTITUDE,
DEFAULT_ALTITUDE,
DOMAIN,
EVENT_OPENSKY_ENTRY,
EVENT_OPENSKY_EXIT,
)

EVENT_OPENSKY_ENTRY = f"{DOMAIN}_entry"
EVENT_OPENSKY_EXIT = f"{DOMAIN}_exit"
# OpenSky free user has 400 credits, with 4 credits per API call. 100/24 = ~4 requests per hour
SCAN_INTERVAL = timedelta(minutes=15)

OPENSKY_API_URL = "https://opensky-network.org/api/states/all"
OPENSKY_API_FIELDS = [
ATTR_ICAO24,
ATTR_CALLSIGN,
"origin_country",
"time_position",
"time_velocity",
ATTR_LONGITUDE,
ATTR_LATITUDE,
ATTR_ALTITUDE,
ATTR_ON_GROUND,
"velocity",
"heading",
"vertical_rate",
"sensors",
]


PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_RADIUS): vol.Coerce(float),
Expand Down

0 comments on commit 9954208

Please sign in to comment.