Skip to content

Commit

Permalink
* Fix data migration
Browse files Browse the repository at this point in the history
  • Loading branch information
BenPru committed Oct 30, 2023
1 parent c81bc1d commit 65bb1f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
9 changes: 3 additions & 6 deletions custom_components/luxtronik/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,10 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
prefix = None
ent_reg = None

def _prepare_up() -> None:
prefix = config_entry.data[CONF_HA_SENSOR_PREFIX]
ent_reg = async_get(hass)

def _up(ident: str, new_id: SK, platform: P = P.SENSOR) -> None:
if prefix is None or ent_reg is None:
prefix = config_entry.data[CONF_HA_SENSOR_PREFIX]
ent_reg = async_get(hass)
entity_id = f"{platform}.{prefix}_{ident}"
new_ident = f"{platform}.{prefix}_{new_id}"
try:
Expand Down Expand Up @@ -139,7 +138,6 @@ def _up(ident: str, new_id: SK, platform: P = P.SENSOR) -> None:
hass.config_entries.async_update_entry(config_entry, data=new_data)

if config_entry.version == 5:
_prepare_up()
_up("heat_amount_domestic_water", SK.DHW_HEAT_AMOUNT)
_up("domestic_water_energy_input", SK.DHW_ENERGY_INPUT)
_up("domestic_water_temperature", SK.DHW_TEMPERATURE)
Expand Down Expand Up @@ -261,7 +259,6 @@ def _up(ident: str, new_id: SK, platform: P = P.SENSOR) -> None:
hass.config_entries.async_update_entry(config_entry, data=new_data)

if config_entry.version == 6:
_prepare_up()
_up(
"cooling_threshold_temperature", SK.COOLING_OUTDOOR_TEMP_THRESHOLD, P.NUMBER
)
Expand Down
4 changes: 0 additions & 4 deletions custom_components/luxtronik/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,6 @@ class LuxtronikOptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry):

_sensor_prefix = DOMAIN

def __init__(self, config_entry):
"""Initialize options flow."""
self.config_entry = config_entry

def _get_value(self, key: str, default=None):
"""Return a value from Luxtronik."""
return self.options.get(key, self.config_entry.data.get(key, default))
Expand Down

0 comments on commit 65bb1f6

Please sign in to comment.