Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 15 additions & 2 deletions custom_components/simple_pid_controller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,29 @@

import logging
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform, ATTR_ENTITY_ID
from homeassistant.const import (
ATTR_ENTITY_ID,
MAJOR_VERSION,
MINOR_VERSION,
Platform,
)
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
from homeassistant.helpers import entity_registry as er
from collections import deque
from dataclasses import dataclass
from simple_pid import PID
import voluptuous as vol
import homeassistant.helpers.config_validation as cv

# Home Assistant 2026.10 replaced voluptuous with probatio, an API-compatible
# successor, and from then on expects probatio schemas. 2026.9 already ships
# probatio but still expects voluptuous ones, so the version decides, not
# whether probatio happens to be importable.
if (MAJOR_VERSION, MINOR_VERSION) >= (2026, 10):
import probatio as vol
else:
import voluptuous as vol # type: ignore[no-redef]

from .coordinator import PIDDataCoordinator

from .const import (
Expand Down
20 changes: 16 additions & 4 deletions custom_components/simple_pid_controller/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@
import logging
from typing import Any

import voluptuous as vol

from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import MAJOR_VERSION, MINOR_VERSION
from homeassistant.core import callback
from homeassistant.helpers.selector import selector

# Home Assistant 2026.10 replaced voluptuous with probatio, an API-compatible
# successor, and from then on expects probatio schemas. 2026.9 already ships
# probatio but still expects voluptuous ones, so the version decides, not
# whether probatio happens to be importable.
if (MAJOR_VERSION, MINOR_VERSION) >= (2026, 10):
import probatio as vol
else:
import voluptuous as vol # type: ignore[no-redef]

from .const import (
DOMAIN,
CONF_NAME,
Expand Down Expand Up @@ -54,7 +62,10 @@ async def async_step_user(
) -> ConfigFlowResult:
"""Handle the initial step."""

schema = vol.Schema(
# Any: whether async_show_form takes a probatio or a voluptuous schema
# depends on the Home Assistant version (see the import above), and the
# pre-commit hook and the lint job type check against different ones.
schema: Any = vol.Schema(
{
vol.Required(CONF_NAME, default=DEFAULT_NAME): str,
vol.Required(CONF_SENSOR_ENTITY_ID): selector(
Expand Down Expand Up @@ -160,7 +171,8 @@ async def async_step_init(
for key in DEFAULT_STEPS
}

options_schema = vol.Schema(
# Any, for the reason given in async_step_user.
options_schema: Any = vol.Schema(
{
vol.Required(
CONF_SENSOR_ENTITY_ID,
Expand Down