Ejemplo n.º 1
0
def get_dtv_data(
    hass: HomeAssistant, host: str, port: int = DEFAULT_PORT, client_addr: str = "0"
) -> dict:
    """Retrieve a DIRECTV instance, locations list, and version info for the receiver device."""
    dtv = DIRECTV(host, port, client_addr, determine_state=False)
    locations = dtv.get_locations()
    version_info = dtv.get_version()

    return {
        DATA_CLIENT: dtv,
        DATA_LOCATIONS: locations,
        DATA_VERSION_INFO: version_info,
    }
Ejemplo n.º 2
0
def validate_input(data: Dict) -> Dict:
    """Validate the user input allows us to connect.

    Data has the keys from DATA_SCHEMA with values provided by the user.
    """
    dtv = DIRECTV(data["host"], DEFAULT_PORT, determine_state=False)
    version_info = dtv.get_version()

    return {
        "title": data["host"],
        "host": data["host"],
        "receiver_id": "".join(version_info["receiverId"].split()),
    }