Skip to content

Commit

Permalink
Commit WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bramstroker committed Aug 12, 2022
1 parent e3c308c commit 18ad075
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion custom_components/powercalc/config_flow.py
Expand Up @@ -632,7 +632,8 @@ def _validate_group_input(user_input: dict[str, str] = None) -> dict:
if (
CONF_SUB_GROUPS not in user_input
and CONF_GROUP_POWER_ENTITIES not in user_input
and CONF_GROUP_ENERGY_ENTITIES not in user_input
and CONF_GROUP_ENERGY_ENTITIES not in user_input
and CONF_GROUP_MEMBER_SENSORS not in user_input
):
errors["base"] = "group_mandatory"

Expand Down
19 changes: 19 additions & 0 deletions tests/test_config_flow.py
Expand Up @@ -397,6 +397,25 @@ async def test_can_select_existing_powercalc_entry_as_group_member(hass: HomeAss
assert {"value": config_entry_1.entry_id, "label": "VirtualPower1"} in options
assert {"value": config_entry_2.entry_id, "label": "VirtualPower2"} not in options

user_input = {
CONF_NAME: "My group sensor",
CONF_UNIQUE_ID: DEFAULT_UNIQUE_ID,
CONF_GROUP_MEMBER_SENSORS: [ config_entry_1.entry_id ],
}
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input
)

assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["data"] == {
CONF_SENSOR_TYPE: SensorType.GROUP,
CONF_NAME: "My group sensor",
CONF_HIDE_MEMBERS: False,
CONF_GROUP_MEMBER_SENSORS: [ config_entry_1.entry_id ],
CONF_UNIQUE_ID: DEFAULT_UNIQUE_ID,
CONF_CREATE_UTILITY_METERS: False,
}

async def test_group_error_mandatory(hass: HomeAssistant):
result = await _select_sensor_type(hass, SensorType.GROUP)
user_input = {CONF_NAME: "My group sensor", CONF_UNIQUE_ID: DEFAULT_UNIQUE_ID}
Expand Down

0 comments on commit 18ad075

Please sign in to comment.