Skip to content

Commit

Permalink
Maggiore protezione contro configurazioni errate
Browse files Browse the repository at this point in the history
  • Loading branch information
virtualdj committed Nov 16, 2024
1 parent 33fd2c3 commit d61e76f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions custom_components/pun_sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ async def update_listener(hass: HomeAssistant, config: ConfigEntry) -> None:
coordinator = hass.data[DOMAIN][config.entry_id]

# Aggiorna le impostazioni del coordinator dalle opzioni
if config.options[CONF_SCAN_HOUR] != coordinator.scan_hour:
if (CONF_SCAN_HOUR in config.options) and (
config.options[CONF_SCAN_HOUR] != coordinator.scan_hour
):
# Modificata l'ora di scansione nelle opzioni
coordinator.scan_hour = config.options[CONF_SCAN_HOUR]

Expand Down Expand Up @@ -107,7 +109,9 @@ async def update_listener(hass: HomeAssistant, config: ConfigEntry) -> None:
next_update_pun.strftime("%d/%m/%Y %H:%M:%S %z"),
)

if config.options[CONF_ACTUAL_DATA_ONLY] != coordinator.actual_data_only:
if (CONF_ACTUAL_DATA_ONLY in config.options) and (
config.options[CONF_ACTUAL_DATA_ONLY] != coordinator.actual_data_only
):
# Modificata impostazione 'Usa dati reali'
coordinator.actual_data_only = config.options[CONF_ACTUAL_DATA_ONLY]
_LOGGER.debug(
Expand Down

0 comments on commit d61e76f

Please sign in to comment.