mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add support for multiple thermostats (via hass-config) and auto-discovery via ratiotherm module
This commit is contained in:
parent
37278aab20
commit
84c72ebf63
@ -26,24 +26,31 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
"Did you maybe not install the radiotherm dependency?")
|
"Did you maybe not install the radiotherm dependency?")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Detect hosts with hass discovery, config or radiotherm discovery
|
||||||
hosts = []
|
hosts = []
|
||||||
logger.info(discovery_info)
|
if discovery_info:
|
||||||
|
logger.info('hass radiotherm discovery', discovery_info)
|
||||||
|
elif CONF_HOST in config:
|
||||||
|
hosts = [config[CONF_HOST]]
|
||||||
|
else:
|
||||||
|
hosts.append(radiotherm.discover.discover_address())
|
||||||
|
|
||||||
|
|
||||||
host = config.get(CONF_HOST)
|
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
if host is None:
|
if hosts is None:
|
||||||
logger.error("host not defined in config.")
|
logger.error("no radiotherm thermostats detected")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
tstats = []
|
||||||
tstat = radiotherm.get_thermostat(host)
|
|
||||||
except URLError:
|
|
||||||
logger.exception(
|
|
||||||
"Unable to connect to Radio Thermostat")
|
|
||||||
return
|
|
||||||
|
|
||||||
add_devices([RadioThermostat(tstat, name)])
|
for host in hosts:
|
||||||
|
try:
|
||||||
|
tstat = radiotherm.get_thermostat(host)
|
||||||
|
tstats.append(RadioThermostat(tstat))
|
||||||
|
except (URLError, OSError):
|
||||||
|
logger.exception(
|
||||||
|
"Unable to connect to Radio Thermostat @{}".format(host))
|
||||||
|
|
||||||
|
add_devices(tstats)
|
||||||
|
|
||||||
|
|
||||||
class RadioThermostat(ThermostatDevice):
|
class RadioThermostat(ThermostatDevice):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user