def setup(hass, config): """Use config values to set up a function enabling status retrieval.""" conf = config[DOMAIN] username = conf.get(CONF_USERNAME) password = conf.get(CONF_PASSWORD) name = conf.get(CONF_NAME) driver = conf.get(CONF_DRIVER) import myusps try: cookie = hass.config.path(COOKIE) cache = hass.config.path(CACHE) session = myusps.get_session(username, password, cookie_path=cookie, cache_path=cache, driver=driver) except myusps.USPSError: _LOGGER.exception('Could not connect to My USPS') return False hass.data[DATA_USPS] = USPSData(session, name) for component in USPS_TYPE: discovery.load_platform(hass, component, DOMAIN, {}, config) return True
def setup(hass, config): """Use config values to set up a function enabling status retrieval.""" conf = config[DOMAIN] username = conf.get(CONF_USERNAME) password = conf.get(CONF_PASSWORD) name = conf.get(CONF_NAME) driver = conf.get(CONF_DRIVER) import myusps try: cookie = hass.config.path(COOKIE) cache = hass.config.path(CACHE) session = myusps.get_session(username, password, cookie_path=cookie, cache_path=cache, driver=driver) except myusps.USPSError: _LOGGER.exception('Could not connect to My USPS') return False hass.data[DATA_USPS] = USPSData(session, name) for component in USPS_TYPE: discovery.load_platform(hass, component, DOMAIN, {}, config) return True
def setup(hass, config): """Use config values to set up a function enabling status retrieval.""" _LOGGER.warning( "The usps 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" ) conf = config[DOMAIN] username = conf.get(CONF_USERNAME) password = conf.get(CONF_PASSWORD) name = conf.get(CONF_NAME) driver = conf.get(CONF_DRIVER) import myusps try: cookie = hass.config.path(COOKIE) cache = hass.config.path(CACHE) session = myusps.get_session(username, password, cookie_path=cookie, cache_path=cache, driver=driver) except myusps.USPSError: _LOGGER.exception("Could not connect to My USPS") return False hass.data[DATA_USPS] = USPSData(session, name) for component in USPS_TYPE: discovery.load_platform(hass, component, DOMAIN, {}, config) return True
def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the USPS platform.""" import myusps try: session = myusps.get_session(config.get(CONF_USERNAME), config.get(CONF_PASSWORD)) except myusps.USPSError: _LOGGER.exception('Could not connect to My USPS') return False add_devices([USPSSensor(session, config.get(CONF_UPDATE_INTERVAL))])
def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the USPS platform.""" import myusps try: session = myusps.get_session(config.get(CONF_USERNAME), config.get(CONF_PASSWORD)) except myusps.USPSError: _LOGGER.exception("Could not connect to My USPS") return False add_devices([USPSSensor(session, config.get(CONF_UPDATE_INTERVAL))])
def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the USPS platform.""" import myusps try: cookie = hass.config.path(COOKIE) session = myusps.get_session( config.get(CONF_USERNAME), config.get(CONF_PASSWORD), cookie_path=cookie) except myusps.USPSError: _LOGGER.exception('Could not connect to My USPS') return False add_devices([USPSPackageSensor(session, config.get(CONF_NAME)), USPSMailSensor(session, config.get(CONF_NAME))], True)
def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the USPS platform.""" import myusps try: cookie = hass.config.path(COOKIE) session = myusps.get_session(config.get(CONF_USERNAME), config.get(CONF_PASSWORD), cookie_path=cookie) except myusps.USPSError: _LOGGER.exception('Could not connect to My USPS') return False add_devices([ USPSPackageSensor(session, config.get(CONF_NAME)), USPSMailSensor(session, config.get(CONF_NAME)) ], True)
imgur_client_secret = "fe1128d77d7ea9d8d9d78805ffb943bbf63d82a2" try: client = ImgurClient(imgur_client_id, imgur_client_secret) except: print("Imgur is down, mail images will not show up") pass # Establish a session. username = os.environ.get('usps_username') password = os.environ.get('usps_password') # Use the login credentials you use to login to My USPS via the web. # A login failure raises a `USPSError`. # Using the Firefox driver here for selenium as it appears to be the most stable one at the moment. session = myusps.get_session(username, password, driver='firefox') # Get all packages that My UPS knows about. packages = myusps.get_packages(session) #Check for packages that haven't been delivered yet upcoming_packages = 0 for p in packages: tracking_number = p['tracking_number'] delivery_date = p['delivery_date'] primary_status = p['primary_status'] #Skip delivered package if primary_status == "Delivered": continue upcoming_packages += 1