Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions custom_components/pun_sensor/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""UI di configurazione per pun_sensor."""

from typing import Any, TypeAlias

from awesomeversion.awesomeversion import AwesomeVersion
import voluptuous as vol

from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlowResult
from homeassistant.const import __version__ as HA_VERSION
from homeassistant.core import callback
from homeassistant.helpers import selector
Expand All @@ -13,6 +14,12 @@
from .const import CONF_ACTUAL_DATA_ONLY, CONF_SCAN_HOUR, CONF_ZONA, DOMAIN
from .interfaces import DEFAULT_ZONA, Zona

# Configurazione del tipo di ritorno compatibile con HA 2023.4.0
if AwesomeVersion(HA_VERSION) >= AwesomeVersion("2024.4.0"):
from homeassistant.config_entries import ConfigFlowResult
else:
ConfigFlowResult: TypeAlias = dict[str, Any] # type: ignore[no-redef]

# Configurazione del selettore compatibile con HA 2023.4.0
selector_config = selector.SelectSelectorConfig(
options=[
Expand All @@ -33,7 +40,7 @@ def __init__(self, entry: config_entries.ConfigEntry) -> None:
if AwesomeVersion(HA_VERSION) < AwesomeVersion("2024.12.0b0"):
self.config_entry = entry

async def async_step_init(self, user_input=None) -> ConfigFlowResult:
async def async_step_init(self, user_input=None) -> ConfigFlowResult | dict: # pyright: ignore[reportInvalidTypeForm]
"""Gestisce le opzioni di configurazione."""
errors: dict[str, str] | None = {}
if user_input is not None:
Expand Down
Loading