Fix tado default overlay for when set pre new overlay feature (#69584)
This commit is contained in:
parent
74bec58bfa
commit
ad946cf9d2
2 changed files with 25 additions and 4 deletions
|
@ -18,7 +18,10 @@ from homeassistant.util import Throttle
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_FALLBACK,
|
CONF_FALLBACK,
|
||||||
|
CONST_OVERLAY_MANUAL,
|
||||||
|
CONST_OVERLAY_TADO_DEFAULT,
|
||||||
CONST_OVERLAY_TADO_MODE,
|
CONST_OVERLAY_TADO_MODE,
|
||||||
|
CONST_OVERLAY_TADO_OPTIONS,
|
||||||
DATA,
|
DATA,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
INSIDE_TEMPERATURE_MEASUREMENT,
|
INSIDE_TEMPERATURE_MEASUREMENT,
|
||||||
|
@ -51,7 +54,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
|
|
||||||
username = entry.data[CONF_USERNAME]
|
username = entry.data[CONF_USERNAME]
|
||||||
password = entry.data[CONF_PASSWORD]
|
password = entry.data[CONF_PASSWORD]
|
||||||
fallback = entry.options.get(CONF_FALLBACK, CONST_OVERLAY_TADO_MODE)
|
fallback = entry.options.get(CONF_FALLBACK, CONST_OVERLAY_TADO_DEFAULT)
|
||||||
|
|
||||||
tadoconnector = TadoConnector(hass, username, password, fallback)
|
tadoconnector = TadoConnector(hass, username, password, fallback)
|
||||||
|
|
||||||
|
@ -99,7 +102,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
def _async_import_options_from_data_if_missing(hass: HomeAssistant, entry: ConfigEntry):
|
def _async_import_options_from_data_if_missing(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
options = dict(entry.options)
|
options = dict(entry.options)
|
||||||
if CONF_FALLBACK not in options:
|
if CONF_FALLBACK not in options:
|
||||||
options[CONF_FALLBACK] = entry.data.get(CONF_FALLBACK, CONST_OVERLAY_TADO_MODE)
|
options[CONF_FALLBACK] = entry.data.get(
|
||||||
|
CONF_FALLBACK, CONST_OVERLAY_TADO_DEFAULT
|
||||||
|
)
|
||||||
|
hass.config_entries.async_update_entry(entry, options=options)
|
||||||
|
|
||||||
|
if options[CONF_FALLBACK] not in CONST_OVERLAY_TADO_OPTIONS:
|
||||||
|
if options[CONF_FALLBACK]:
|
||||||
|
options[CONF_FALLBACK] = CONST_OVERLAY_TADO_MODE
|
||||||
|
else:
|
||||||
|
options[CONF_FALLBACK] = CONST_OVERLAY_MANUAL
|
||||||
hass.config_entries.async_update_entry(entry, options=options)
|
hass.config_entries.async_update_entry(entry, options=options)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,13 @@ from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
|
|
||||||
from .const import CONF_FALLBACK, CONST_OVERLAY_TADO_OPTIONS, DOMAIN, UNIQUE_ID
|
from .const import (
|
||||||
|
CONF_FALLBACK,
|
||||||
|
CONST_OVERLAY_TADO_DEFAULT,
|
||||||
|
CONST_OVERLAY_TADO_OPTIONS,
|
||||||
|
DOMAIN,
|
||||||
|
UNIQUE_ID,
|
||||||
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -126,7 +132,10 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||||
data_schema = vol.Schema(
|
data_schema = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Optional(
|
vol.Optional(
|
||||||
CONF_FALLBACK, default=self.config_entry.options.get(CONF_FALLBACK)
|
CONF_FALLBACK,
|
||||||
|
default=self.config_entry.options.get(
|
||||||
|
CONF_FALLBACK, CONST_OVERLAY_TADO_DEFAULT
|
||||||
|
),
|
||||||
): vol.In(CONST_OVERLAY_TADO_OPTIONS),
|
): vol.In(CONST_OVERLAY_TADO_OPTIONS),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue