def setup_platform(hass, config, add_devices, discovery_info=None): """Setup oemthermostat.""" from oemthermostat import Thermostat # Assign configuration variables. The configuration check takes care they # are present. name = config.get(CONF_NAME) host = config.get(CONF_HOST) port = config.get(CONF_PORT) username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) away_temp = config.get(CONF_AWAY_TEMP) # If creating the class raises an exception, it failed to connect or # something else went wrong. try: therm = Thermostat(host, port=port, username=username, password=password) except (ValueError, AssertionError, requests.RequestException): return False # Add devices add_devices((ThermostatDevice(hass, therm, name, away_temp), ), True)
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the oemthermostat platform.""" name = config.get(CONF_NAME) host = config.get(CONF_HOST) port = config.get(CONF_PORT) username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) try: therm = Thermostat(host, port=port, username=username, password=password) except (ValueError, AssertionError, requests.RequestException): return False add_entities((ThermostatDevice(therm, name), ), True)
def setup_platform( hass: HomeAssistant, config: ConfigType, add_entities: AddEntitiesCallback, discovery_info: DiscoveryInfoType | None = None, ) -> None: """Set up the oemthermostat platform.""" name = config.get(CONF_NAME) host = config.get(CONF_HOST) port = config.get(CONF_PORT) username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) try: therm = Thermostat(host, port=port, username=username, password=password) except (ValueError, AssertionError, requests.RequestException): return add_entities((ThermostatDevice(therm, name),), True)