"""
Check whether Raspberry Pi 1-Wire and SPI interfaces are visible.
"""

from pathlib import Path


def state(
    available: bool,
) -> str:
    """Return a compact status label."""
    return "OK" if available else "NOT FOUND"


def main() -> None:
    """Print hardware interface availability."""
    w1_root = Path(
        "/sys/bus/w1/devices"
    )

    spi_devices = sorted(
        Path("/dev").glob("spidev*")
    )

    print("Sentinel hardware interface check")
    print("---------------------------------")
    print(
        "1-Wire: "
        + state(w1_root.exists())
    )
    print(
        "SPI:    "
        + state(bool(spi_devices))
    )

    if spi_devices:
        print(
            "SPI devices: "
            + ", ".join(
                str(path)
                for path in spi_devices
            )
        )

    print()
    print(
        "If an interface is missing, enable it with "
        "raspi-config before connecting sensors."
    )


if __name__ == "__main__":
    main()
