diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8c5560a..095fa6d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,8 +49,9 @@ repos: rev: v1.13.0 hooks: - id: mypy - additional_dependencies: [pytest] + additional_dependencies: [pytest, homeassistant] args: - --pretty - --show-error-codes - - --show-error-context \ No newline at end of file + - --show-error-context + - -v \ No newline at end of file diff --git a/custom_components/askoheat/config_flow.py b/custom_components/askoheat/config_flow.py index 22d1685..c2528ff 100644 --- a/custom_components/askoheat/config_flow.py +++ b/custom_components/askoheat/config_flow.py @@ -7,9 +7,10 @@ import homeassistant.helpers.config_validation as cv import voluptuous as vol -from homeassistant import config_entries, data_entry_flow +from homeassistant import data_entry_flow from homeassistant.components.sensor.const import SensorDeviceClass from homeassistant.config_entries import ( + ConfigFlow, ConfigFlowResult, OptionsFlow, OptionsFlowWithConfigEntry, @@ -108,7 +109,8 @@ def _step_user_data_schema( filter=selector.EntityFilterSelectorConfig( domain=Platform.SENSOR, device_class=SensorDeviceClass.POWER, - ) + ), + multiple=False, ) ), vol.Required( @@ -194,7 +196,7 @@ def _step_user_data_schema( STEP_USER_DATA_SCHEMA = _step_user_data_schema() -class AskoheatFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class AskoheatFlowHandler(ConfigFlow, domain=DOMAIN): """Config flow for Blueprint.""" VERSION = 1 diff --git a/custom_components/askoheat/switch.py b/custom_components/askoheat/switch.py index 5844417..2576b1e 100644 --- a/custom_components/askoheat/switch.py +++ b/custom_components/askoheat/switch.py @@ -6,6 +6,7 @@ from homeassistant.components.switch import ENTITY_ID_FORMAT, SwitchEntity from homeassistant.core import Event, EventStateChangedData, HomeAssistant, callback +from homeassistant.exceptions import ConfigEntryError from homeassistant.helpers.event import async_track_state_change_event from custom_components.askoheat.api_conf_desc import ( @@ -78,7 +79,10 @@ def config_power_entity() -> str | None: if entity_description.device_key is None or entity_description.device_key in entry.runtime_data.supported_devices ) - if power_entity_id is not None: + if power_entity_id is not None and power_entity_id != []: + if isinstance(power_entity_id, list) and len(power_entity_id) != 1: + msg = "Cannot track multiple power_entities" + raise ConfigEntryError(msg) def config_power_invert() -> bool | None: dev = entry.data.get(CONF_FEED_IN)