def __init__(self, config_filename: str = None, config: dict = None): """Override the __init___ and set the request format arg.""" self.opt_format = request.args.get("format") if self.opt_format is None: self.opt_format = JSON if config_filename is None: Ecobee.__init__(self, config=config) else: Ecobee.__init__(self, config_filename=config_filename)
class EcobeeData(object): """ Gets the latest data and update the states. """ def __init__(self, config_file): from pyecobee import Ecobee self.ecobee = Ecobee(config_file) @Throttle(MIN_TIME_BETWEEN_UPDATES) def update(self): """ Get the latest data from pyecobee. """ self.ecobee.update() _LOGGER.info("ecobee data updated successfully.")
class EcobeeData: """Get the latest data and update the states.""" def __init__(self, config_file): """Init the Ecobee data object.""" from pyecobee import Ecobee self.ecobee = Ecobee(config_file) @Throttle(MIN_TIME_BETWEEN_UPDATES) def update(self): """Get the latest data from pyecobee.""" self.ecobee.update() _LOGGER.debug("Ecobee data updated successfully")
async def async_step_user(self, user_input=None): """Handle a flow initiated by the user.""" if self._async_current_entries(): # Config entry already exists, only one allowed. return self.async_abort(reason="single_instance_allowed") errors = {} stored_api_key = (self.hass.data[DATA_ECOBEE_CONFIG].get(CONF_API_KEY) if DATA_ECOBEE_CONFIG in self.hass.data else "") if user_input is not None: # Use the user-supplied API key to attempt to obtain a PIN from ecobee. self._ecobee = Ecobee( config={ECOBEE_API_KEY: user_input[CONF_API_KEY]}) if await self.hass.async_add_executor_job(self._ecobee.request_pin ): # We have a PIN; move to the next step of the flow. return await self.async_step_authorize() errors["base"] = "pin_request_failed" return self.async_show_form( step_id="user", data_schema=vol.Schema( {vol.Required(CONF_API_KEY, default=stored_api_key): str}), errors=errors, )
def __init__(self, hass, entry, api_key, refresh_token): """Initialize the Ecobee data object.""" self._hass = hass self._entry = entry self.ecobee = Ecobee( config={ECOBEE_API_KEY: api_key, ECOBEE_REFRESH_TOKEN: refresh_token} )
async def async_step_import(self, import_data): """ Import ecobee config from configuration.yaml. Triggered by async_setup only if a config entry doesn't already exist. If ecobee.conf exists, we will attempt to validate the credentials and create an entry if valid. Otherwise, we will delegate to the user step so that the user can continue the config flow. """ try: legacy_config = await self.hass.async_add_executor_job( load_json, self.hass.config.path(ECOBEE_CONFIG_FILENAME) ) config = { ECOBEE_API_KEY: legacy_config[ECOBEE_API_KEY], ECOBEE_REFRESH_TOKEN: legacy_config[ECOBEE_REFRESH_TOKEN], } except (HomeAssistantError, KeyError): _LOGGER.debug( "No valid ecobee.conf configuration found for import, delegating to user step" ) return await self.async_step_user( user_input={ CONF_API_KEY: self.hass.data[DATA_ECOBEE_CONFIG].get(CONF_API_KEY) } ) ecobee = Ecobee(config=config) if await self.hass.async_add_executor_job(ecobee.refresh_tokens): # Credentials found and validated; create the entry. _LOGGER.debug( "Valid ecobee configuration found for import, creating configuration entry" ) return self.async_create_entry( title=DOMAIN, data={ CONF_API_KEY: ecobee.api_key, CONF_REFRESH_TOKEN: ecobee.refresh_token, }, ) return await self.async_step_user( user_input={ CONF_API_KEY: self.hass.data[DATA_ECOBEE_CONFIG].get(CONF_API_KEY) } )
def __init__(self, config_file): """Initialize the Ecobee data object.""" from pyecobee import Ecobee self.ecobee = Ecobee(config_file)
def __init__(self, config_file): from pyecobee import Ecobee self.ecobee = Ecobee(config_file)
heat_off_threshold = config.getint('main', 'heat_off_threshold') heat_on_setpoint = config.getint('main', 'heat_on_setpoint') heat_off_setpoint = config.getint('main', 'heat_off_setpoint') influx_host = config.get('db', 'influx_host') influx_port = config.getint('db', 'influx_port') influx_dbname = config.get('db', 'influx_dbname') poll_time = gmtime() metrics = [] #poll room temp temp = fetch_room_temperature(location, metrics) #fetch thermostat info once ecobee = Ecobee(config_filename='ecobee_config.json') ecobee.write_tokens_to_file() thermostats = ecobee.get_thermostats() log_short_status(thermostats[0]) current_heat_setpoint = getHeatSetPoint(thermostats[0]) if not args.adjust_temp: log.info("DRY RUN MODE. CHECKING TEMP ONLY") if current_heat_setpoint < heat_off_setpoint or current_heat_setpoint > heat_on_setpoint: log.warning( "OVERRIDE DETECTED: Current thermostat setpoint of %s is outside program range of %s to %s. Not adjusting temperature." % (current_heat_setpoint, heat_off_setpoint, heat_on_setpoint)) args.adjust_temp = False