Skip to content

Papua New Guinea ๐Ÿ‡ต๐Ÿ‡ฌ CASA PNG Registry โ€‹

Namepg-casapng-registry
CountryPapua New Guinea
Registration prefixP2-
Data sourcehttps://casapng.gov.pg/safety-regulatory/airworthiness/Aircraft-Registers/
FormatPDF (date-stamped filename, discovered via index page)
Run frequencyMonthly (day 1, 11:10 UTC)
Depends on Mictronics for ICAO hexYes โ€” this runner does not publish ICAO hex addresses; registrations are resolved via RediSearch against Mictronics records (idx:aircraft:mictronics). Must run after the mictronics runner.

How it works โ€‹

The CASA PNG index page is scraped with BeautifulSoup for the first link ending in .pdf โ€” that is always the current register. The PDF has no header row, so pdfplumber's extract_table() result is read by fixed column position (registration, manufacturer, model, operator, address) rather than by name; only rows whose registration starts with P2- are kept. Registrations are then looked up in batches of 100 against the Redis Mictronics search index (RediSearch TagField query) to resolve icao_hex โ€” any registration not yet present in Mictronics is silently skipped for this run. The address field is comma-delimited with embedded newlines (collapsed to spaces); the last comma-separated segment is treated as the country (PNG is expanded to Papua New Guinea) and the remainder as the street. Manufacturer, model, and operator are also whitespace-collapsed like the address field, since pdfplumber can represent a wrapped cell's text with an embedded newline rather than a space. Every written record explicitly sets military: false โ€” this register is exclusively civil, and the explicit value ensures a stale military: true flag (from Mictronics or a prior record on a reused hex) is corrected on re-registration.

Columns โ€‹

Source columnImportedNotes
Registration (col 0)โœ…P2- filter; used as the Mictronics lookup key
Manufacturer (col 1)โœ…โ†’ aircraft.manufacturer; embedded newlines collapsed to a single space
Model (col 2)โœ…โ†’ aircraft.model; embedded newlines collapsed to a single space
Operator (col 3)โœ…โ†’ registrant.names[0]; embedded newlines collapsed to a single space
Address (col 4)โœ…Comma-delimited; last segment โ†’ registrant.country (PNG expanded), remainder โ†’ registrant.street

See specs/data-dictionary.yaml (pg-casapng-registry entry) for full column semantics and cross-source schema notes.

Example Output โ€‹

Read back the merged record for a given ICAO hex (combines this runner's data with Mictronics and any other sources that have written to the same key):

bash
docker run --rm --network host redis:latest redis-cli EVAL "$(cat ./shared/lua/merge_aircraft.lua)" 0 898104 | python3 -m json.tool --sort-keys --no-ensure-ascii
json
{
    "aircraft": {
        "manufacturer": "CESSNA",
        "manufacturer_model": "CESSNA 208 Caravan",
        "model": "208",
        "type_designator": "C208"
    },
    "data_sources": [
        "mictronics",
        "pg-casapng-registry"
    ],
    "icao_hex": "898104",
    "military": false,
    "registrant": {
        "country": "MT HAGEN WESTERN HIGHLANDS PROVINCE",
        "names": [
            "MISSION AVIATION FELLOWSHIP"
        ],
        "street": "PO BOX 273"
    },
    "registration": "P2-MAI"
}
bash
docker run --rm --network host redis:latest redis-cli EVAL "$(cat ./shared/lua/merge_aircraft.lua)" 0 898174 | python3 -m json.tool --sort-keys --no-ensure-ascii
json
{
    "aircraft": {
        "manufacturer": "BOEING",
        "manufacturer_model": "BOEING 737-800",
        "model": "737",
        "type_designator": "B738"
    },
    "data_sources": [
        "mictronics",
        "pg-casapng-registry",
        "airportwebcams-special-liveries"
    ],
    "icao_hex": "898174",
    "military": false,
    "registrant": {
        "country": "Papua New Guinea",
        "names": [
            "AIR NIUGINI"
        ],
        "street": "P.O.BOX 7186, BOROKO NCD"
    },
    "registration": "P2-PXB",
    "special_livery": "50 Years"
}

Note: the small example (P2-MAI, Cessna 208 Caravan) is a single-engine turboprop rather than a 150/172 โ€” this registry has no lighter GA singles, so a turboprop stands in as the "small" example.

Configuration โ€‹

See Data Runners for the full list of environment variables every runner reads. This runner writes aircraft:registry:{icao_hex} with a fixed 14-day TTL (ENRICHMENT_TTL_SECONDS in shared/timing.py).

MQTT โ€‹

Published once, at the end of a run, to SkyFollower/runner/pg-casapng-registry/statistic/{name} (all retained):

Topic suffixValueFormat
records_importede.g. 271Integer as string
last_run_ate.g. 2026-07-07T14:32:01.123456+00:00ISO 8601 UTC
last_run_statusSuccess or FailureString

Home Assistant autodiscovery configs are also published (retained) to homeassistant/sensor/SkyFollower_runner_pg_casapng_registry_{name}/config for each of the three stats above.