Initil after Upgrade

This commit is contained in:
2026-06-15 10:53:52 -04:00
parent 2fe9bf0dd6
commit 887feaa50a
143 changed files with 2288 additions and 881 deletions
@@ -3,8 +3,8 @@ from __future__ import annotations
from datetime import timedelta
from typing import TYPE_CHECKING, Any
from homeassistant.config_entries import ConfigFlowResult
from homeassistant.const import CONF_ENABLED, CONF_SENSORS, UnitOfTime
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import selector
from homeassistant.helpers.typing import ConfigType
import voluptuous as vol
@@ -44,7 +44,11 @@ from custom_components.powercalc.const import (
ENTRY_GLOBAL_CONFIG_UNIQUE_ID,
)
from custom_components.powercalc.flow_helper.common import PowercalcFormStep, Step
from custom_components.powercalc.flow_helper.schema import SCHEMA_ENERGY_OPTIONS, SCHEMA_UTILITY_METER_OPTIONS, SCHEMA_UTILITY_METER_TOGGLE
from custom_components.powercalc.flow_helper.schema import (
SCHEMA_ENERGY_OPTIONS,
SCHEMA_UTILITY_METER_OPTIONS,
SCHEMA_UTILITY_METER_TOGGLE,
)
if TYPE_CHECKING:
from custom_components.powercalc.config_flow import PowercalcCommonFlow, PowercalcConfigFlow, PowercalcOptionsFlow
@@ -95,10 +99,16 @@ SCHEMA_GLOBAL_CONFIGURATION_THROTTLING = vol.Schema(
vol.Optional(CONF_ENERGY_UPDATE_INTERVAL, default=DEFAULT_ENERGY_UPDATE_INTERVAL): selector.NumberSelector(
selector.NumberSelectorConfig(unit_of_measurement=UnitOfTime.SECONDS, mode=selector.NumberSelectorMode.BOX),
),
vol.Optional(CONF_GROUP_POWER_UPDATE_INTERVAL, default=DEFAULT_GROUP_POWER_UPDATE_INTERVAL): selector.NumberSelector(
vol.Optional(
CONF_GROUP_POWER_UPDATE_INTERVAL,
default=DEFAULT_GROUP_POWER_UPDATE_INTERVAL,
): selector.NumberSelector(
selector.NumberSelectorConfig(unit_of_measurement=UnitOfTime.SECONDS, mode=selector.NumberSelectorMode.BOX),
),
vol.Optional(CONF_GROUP_ENERGY_UPDATE_INTERVAL, default=DEFAULT_GROUP_ENERGY_UPDATE_INTERVAL): selector.NumberSelector(
vol.Optional(
CONF_GROUP_ENERGY_UPDATE_INTERVAL,
default=DEFAULT_GROUP_ENERGY_UPDATE_INTERVAL,
): selector.NumberSelector(
selector.NumberSelectorConfig(unit_of_measurement=UnitOfTime.SECONDS, mode=selector.NumberSelectorMode.BOX),
),
},
@@ -141,7 +151,10 @@ class GlobalConfigurationFlow:
def __init__(self, flow: PowercalcCommonFlow) -> None:
self.flow = flow
async def async_step_global_configuration_discovery(self, user_input: dict[str, Any] | None = None) -> FlowResult:
async def async_step_global_configuration_discovery(
self,
user_input: dict[str, Any] | None = None,
) -> ConfigFlowResult:
"""Handle the discovery configuration step."""
if user_input is not None:
@@ -162,7 +175,10 @@ class GlobalConfigurationFlow:
user_input,
)
async def async_step_global_configuration_throttling(self, user_input: dict[str, Any] | None = None) -> FlowResult:
async def async_step_global_configuration_throttling(
self,
user_input: dict[str, Any] | None = None,
) -> ConfigFlowResult:
"""Handle the throttling related options."""
if user_input is not None:
@@ -184,7 +200,10 @@ class GlobalConfigurationFlow:
user_input,
)
async def async_step_global_configuration_energy(self, user_input: dict[str, Any] | None = None) -> FlowResult:
async def async_step_global_configuration_energy(
self,
user_input: dict[str, Any] | None = None,
) -> ConfigFlowResult:
"""Handle the global configuration step."""
if user_input is not None:
@@ -199,11 +218,18 @@ class GlobalConfigurationFlow:
PowercalcFormStep(
step=Step.GLOBAL_CONFIGURATION_ENERGY,
schema=SCHEMA_GLOBAL_CONFIGURATION_ENERGY_SENSOR,
form_kwarg={"description_placeholders": {"docs_uri": "https://docs.powercalc.nl/configuration/global-configuration/"}},
form_kwarg={
"description_placeholders": {
"docs_uri": "https://docs.powercalc.nl/configuration/global-configuration/",
},
},
),
)
async def async_step_global_configuration_utility_meter(self, user_input: dict[str, Any] | None = None) -> FlowResult:
async def async_step_global_configuration_utility_meter(
self,
user_input: dict[str, Any] | None = None,
) -> ConfigFlowResult:
"""Handle the global configuration step."""
if user_input is not None:
@@ -212,7 +238,7 @@ class GlobalConfigurationFlow:
return self.flow.persist_config_entry()
if not bool(self.flow.global_config.get(CONF_CREATE_UTILITY_METERS)) or user_input is not None:
return self.flow.async_create_entry( # type: ignore
return self.flow.async_create_entry(
title="Global Configuration",
data=self.flow.global_config,
)
@@ -221,7 +247,11 @@ class GlobalConfigurationFlow:
PowercalcFormStep(
step=Step.GLOBAL_CONFIGURATION_UTILITY_METER,
schema=SCHEMA_UTILITY_METER_OPTIONS,
form_kwarg={"description_placeholders": {"docs_uri": "https://docs.powercalc.nl/configuration/global-configuration/"}},
form_kwarg={
"description_placeholders": {
"docs_uri": "https://docs.powercalc.nl/configuration/global-configuration/",
},
},
),
)
@@ -231,7 +261,7 @@ class GlobalConfigurationConfigFlow(GlobalConfigurationFlow):
super().__init__(flow)
self.flow: PowercalcConfigFlow = flow
async def async_step_global_configuration(self, user_input: dict[str, Any] | None = None) -> FlowResult:
async def async_step_global_configuration(self, user_input: dict[str, Any] | None = None) -> ConfigFlowResult:
"""Handle the global configuration step."""
get_global_powercalc_config(self.flow)
await self.flow.async_set_unique_id(ENTRY_GLOBAL_CONFIG_UNIQUE_ID)
@@ -272,7 +302,7 @@ class GlobalConfigurationOptionsFlow(GlobalConfigurationFlow):
menu[Step.GLOBAL_CONFIGURATION_UTILITY_METER] = "Utility meter options"
return menu
async def async_step_global_configuration(self, user_input: dict[str, Any] | None = None) -> FlowResult:
async def async_step_global_configuration(self, user_input: dict[str, Any] | None = None) -> ConfigFlowResult:
"""Handle the global configuration step."""
if user_input is not None: