Add opentherm_gw config flow (#27148)
* Add config flow support to opentherm_gw. Bump pyotgw to 0.5b0 (required for connection testing) Existing entries in configuration.yaml will be converted to config entries and ignored in future runs. * Fix not connecting to Gateway on startup. Pylint fixes. * Add tests for config flow. Remove non-essential options from config flow. Restructure config entry data. * Make sure gw_id is slugified
This commit is contained in:
parent
2e49303401
commit
6ae908b883
17 changed files with 413 additions and 50 deletions
|
@ -17,6 +17,7 @@ from homeassistant.components.climate.const import (
|
|||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_TEMPERATURE,
|
||||
CONF_ID,
|
||||
PRECISION_HALVES,
|
||||
PRECISION_TENTHS,
|
||||
PRECISION_WHOLE,
|
||||
|
@ -33,12 +34,16 @@ _LOGGER = logging.getLogger(__name__)
|
|||
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
"""Set up the opentherm_gw device."""
|
||||
gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][discovery_info]
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up an OpenTherm Gateway climate entity."""
|
||||
ents = []
|
||||
ents.append(
|
||||
OpenThermClimate(
|
||||
hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][config_entry.data[CONF_ID]]
|
||||
)
|
||||
)
|
||||
|
||||
gateway = OpenThermClimate(gw_dev)
|
||||
async_add_entities([gateway])
|
||||
async_add_entities(ents)
|
||||
|
||||
|
||||
class OpenThermClimate(ClimateDevice):
|
||||
|
@ -48,7 +53,7 @@ class OpenThermClimate(ClimateDevice):
|
|||
"""Initialize the device."""
|
||||
self._gateway = gw_dev
|
||||
self.friendly_name = gw_dev.name
|
||||
self.floor_temp = gw_dev.climate_config[CONF_FLOOR_TEMP]
|
||||
self.floor_temp = gw_dev.climate_config.get(CONF_FLOOR_TEMP)
|
||||
self.temp_precision = gw_dev.climate_config.get(CONF_PRECISION)
|
||||
self._current_operation = None
|
||||
self._current_temperature = None
|
||||
|
@ -62,7 +67,7 @@ class OpenThermClimate(ClimateDevice):
|
|||
|
||||
async def async_added_to_hass(self):
|
||||
"""Connect to the OpenTherm Gateway device."""
|
||||
_LOGGER.debug("Added device %s", self.friendly_name)
|
||||
_LOGGER.debug("Added OpenTherm Gateway climate device %s", self.friendly_name)
|
||||
async_dispatcher_connect(
|
||||
self.hass, self._gateway.update_signal, self.receive_report
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue