Skip to content

Commit

Permalink
Fix entities are not unhidden when forced hidden by user (#1269)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramstroker committed Nov 13, 2022
1 parent 11ab77c commit 9ab2901
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions custom_components/powercalc/sensors/group.py
Expand Up @@ -390,6 +390,10 @@ def _async_hide_members(self, hide: True) -> None:
if not registry_entry:
continue

# We don't want to touch devices which are forced hidden by the user
if registry_entry.hidden_by == er.RegistryEntryHider.USER:
continue

hidden_by = er.RegistryEntryHider.INTEGRATION if hide else None
registry.async_update_entity(entity_id, hidden_by=hidden_by)

Expand Down
28 changes: 28 additions & 0 deletions tests/sensors/test_group.py
Expand Up @@ -394,6 +394,34 @@ async def test_unhide_members(hass: HomeAssistant):
assert entity_reg.async_get("sensor.test_power").hidden_by is None


async def test_user_hidden_entities_remain_hidden(hass: HomeAssistant) -> None:
entity_reg = er.async_get(hass)
entity_reg.async_get_or_create(
SENSOR_DOMAIN,
DOMAIN,
"abcdef",
suggested_object_id="test_power",
hidden_by=er.RegistryEntryHider.USER,
)
await hass.async_block_till_done()

await run_powercalc_setup_yaml_config(
hass,
{
CONF_CREATE_GROUP: "TestGroup",
CONF_HIDE_MEMBERS: False,
CONF_ENTITIES: [
{
CONF_ENTITY_ID: DUMMY_ENTITY_ID,
CONF_POWER_SENSOR_ID: "sensor.test_power",
},
],
},
)

assert entity_reg.async_get("sensor.test_power").hidden_by is er.RegistryEntryHider.USER


async def test_members_are_unhiden_after_group_removed(
hass: HomeAssistant, entity_reg: EntityRegistry
):
Expand Down

0 comments on commit 9ab2901

Please sign in to comment.