def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the thermoworks sensor.""" import thermoworks_smoke from requests.exceptions import HTTPError email = config[CONF_EMAIL] password = config[CONF_PASSWORD] monitored_variables = config[CONF_MONITORED_CONDITIONS] excluded = config[CONF_EXCLUDE] try: mgr = thermoworks_smoke.initialize_app(email, password, True, excluded) # list of sensor devices dev = [] # get list of registered devices for serial in mgr.serials(): for variable in monitored_variables: dev.append(ThermoworksSmokeSensor(variable, serial, mgr)) add_entities(dev, True) except HTTPError as error: msg = f"{error.strerror}" if "EMAIL_NOT_FOUND" in msg or "INVALID_PASSWORD" in msg: _LOGGER.error("Invalid email and password combination") else: _LOGGER.error(msg)
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the thermoworks sensor.""" import thermoworks_smoke from requests.exceptions import HTTPError email = config[CONF_EMAIL] password = config[CONF_PASSWORD] monitored_variables = config[CONF_MONITORED_CONDITIONS] excluded = config[CONF_EXCLUDE] try: mgr = thermoworks_smoke.initialize_app(email, password, True, excluded) # list of sensor devices dev = [] # get list of registered devices for serial in mgr.serials(): for variable in monitored_variables: dev.append(ThermoworksSmokeSensor(variable, serial, mgr)) add_entities(dev, True) except HTTPError as error: msg = "{}".format(error.strerror) if 'EMAIL_NOT_FOUND' in msg or \ 'INVALID_PASSWORD' in msg: _LOGGER.error("Invalid email and password combination") else: _LOGGER.error(msg)
def main() -> int: parser = argparse.ArgumentParser( description="Pull Smoke Gateway Temperatures") parser.add_argument('-e', '--email', metavar='email', required=True, help="Account email address") parser.add_argument('-p', '--password', metavar='password', required=True, help="Account password") args = parser.parse_args() email = args.email password = args.password # init mgr = None try: mgr = thermoworks_smoke.initialize_app(email, password, True) except HTTPError as error: msg = "{}".format(error.strerror) if 'EMAIL_NOT_FOUND' in msg or \ "INVALID_PASSWORD" in msg: print("Invalid email and password combination") else: print(msg) return 1 # get list of registered devices serials = mgr.serials() # print data for each serial for serial in serials: values = mgr.data(serial) values['serial'] = serial print(values) return 0