Exemple #1
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the UPS platform."""
    import upsmychoice

    _LOGGER.warning(
        "The ups integration is deprecated and will be removed "
        "in Home Assistant 0.100.0. For more information see ADR-0004:"
        "https://github.com/home-assistant/architecture/blob/master/adr/0004-webscraping.md"
    )

    try:
        cookie = hass.config.path(COOKIE)
        session = upsmychoice.get_session(config.get(CONF_USERNAME),
                                          config.get(CONF_PASSWORD),
                                          cookie_path=cookie)
    except upsmychoice.UPSError:
        _LOGGER.exception("Could not connect to UPS My Choice")
        return False

    add_entities(
        [
            UPSSensor(
                session,
                config.get(CONF_NAME),
                config.get(CONF_SCAN_INTERVAL, SCAN_INTERVAL),
            )
        ],
        True,
    )
Exemple #2
0
def UPSPackage(user, psswd):
    print(user)
    print(psswd)
    try:
        session = upsmychoice.get_session(user, psswd)
        #print(session.status_code)
    except:
        df3 = pd.DataFrame()
        print("invalid credentials")
        return df3, "skip"
    packages = upsmychoice.get_packages(session)
    filename = "UPS_" + user + "_" + psswd + ".csv"
    df1 = pd.DataFrame(packages)
    #df1 = df1[df1["status"] != "Delivered"]
    df1.drop(["estimated_delivery_timeframe"], axis=1, inplace=True)

    df1.drop(["delivery_date"], axis=1, inplace=True)

    df1.drop(["from"], axis=1, inplace=True)

    df1.drop(["from_location"], axis=1, inplace=True)
    ups = []
    for i in range(len(df1)):
        ups.append("UPS")

    dd = pd.DataFrame({'carrier': ups})

    df1 = pd.concat([dd, df1], axis=1)

    print(df1)

    return df1, "valid"
Exemple #3
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the UPS platform."""
    import upsmychoice
    try:
        cookie = hass.config.path(COOKIE)
        session = upsmychoice.get_session(
            config.get(CONF_USERNAME), config.get(CONF_PASSWORD),
            cookie_path=cookie)
    except upsmychoice.UPSError:
        _LOGGER.exception("Could not connect to UPS My Choice")
        return False

    add_devices([UPSSensor(session, config.get(CONF_NAME),
                           config.get(CONF_UPDATE_INTERVAL))])
Exemple #4
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the UPS platform."""
    import upsmychoice
    try:
        cookie = hass.config.path(COOKIE)
        session = upsmychoice.get_session(config.get(CONF_USERNAME),
                                          config.get(CONF_PASSWORD),
                                          cookie_path=cookie)
    except upsmychoice.UPSError:
        _LOGGER.exception("Could not connect to UPS My Choice")
        return False

    add_entities([
        UPSSensor(session, config.get(CONF_NAME),
                  config.get(CONF_SCAN_INTERVAL, SCAN_INTERVAL))
    ], True)