Skip to content

Commit

Permalink
fixed configuration with empty power sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
toggm committed Dec 19, 2024
1 parent 3605012 commit 5ae5db4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- --show-error-context
- -v
8 changes: 5 additions & 3 deletions custom_components/askoheat/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -108,7 +109,8 @@ def _step_user_data_schema(
filter=selector.EntityFilterSelectorConfig(
domain=Platform.SENSOR,
device_class=SensorDeviceClass.POWER,
)
),
multiple=False,
)
),
vol.Required(
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion custom_components/askoheat/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5ae5db4

Please sign in to comment.