Skip to content

Commit

Permalink
Avoid use of hidden entities for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
dermotduffy committed Jun 5, 2022
1 parent f052d76 commit 52dae45
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 25 deletions.
1 change: 0 additions & 1 deletion custom_components/frigate/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def __init__(
self._obj_name = obj_name
self._is_on = False
self._frigate_config = frigate_config
self._attr_entity_registry_visible_default = obj_name != "all"

super().__init__(
config_entry,
Expand Down
1 change: 0 additions & 1 deletion custom_components/frigate/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ def __init__(
self._cam_name = cam_name
self._obj_name = obj_name
self._last_image: bytes | None = None
self._attr_entity_registry_visible_default = False

FrigateMQTTEntity.__init__(
self,
Expand Down
4 changes: 0 additions & 4 deletions custom_components/frigate/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def __init__(
FrigateEntity.__init__(self, config_entry)
CoordinatorEntity.__init__(self, coordinator)
self._attr_entity_registry_enabled_default = False
self._attr_entity_registry_visible_default = False

@property
def unique_id(self) -> str:
Expand Down Expand Up @@ -150,7 +149,6 @@ def __init__(
CoordinatorEntity.__init__(self, coordinator)
self._detector_name = detector_name
self._attr_entity_registry_enabled_default = False
self._attr_entity_registry_visible_default = False

@property
def unique_id(self) -> str:
Expand Down Expand Up @@ -220,7 +218,6 @@ def __init__(
self._cam_name = cam_name
self._fps_type = fps_type
self._attr_entity_registry_enabled_default = False
self._attr_entity_registry_visible_default = False

@property
def unique_id(self) -> str:
Expand Down Expand Up @@ -291,7 +288,6 @@ def __init__(
self._obj_name = obj_name
self._state = 0
self._frigate_config = frigate_config
self._attr_entity_registry_visible_default = False

if self._obj_name == "person":
self._icon = ICON_PERSON
Expand Down
14 changes: 5 additions & 9 deletions custom_components/frigate/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@ async def async_setup_entry(
for camera in frigate_config["cameras"].keys():
entities.extend(
[
FrigateSwitch(entry, frigate_config, camera, "detect", True, False),
FrigateSwitch(entry, frigate_config, camera, "motion", True, False),
FrigateSwitch(entry, frigate_config, camera, "recordings", True, True),
FrigateSwitch(entry, frigate_config, camera, "snapshots", True, True),
FrigateSwitch(
entry, frigate_config, camera, "improve_contrast", False, False
),
FrigateSwitch(entry, frigate_config, camera, "detect", True),
FrigateSwitch(entry, frigate_config, camera, "motion", True),
FrigateSwitch(entry, frigate_config, camera, "recordings", True),
FrigateSwitch(entry, frigate_config, camera, "snapshots", True),
FrigateSwitch(entry, frigate_config, camera, "improve_contrast", False),
]
)
async_add_entities(entities)
Expand All @@ -66,7 +64,6 @@ def __init__(
cam_name: str,
switch_name: str,
default_enabled: bool,
default_visible: bool,
) -> None:
"""Construct a FrigateSwitch."""

Expand All @@ -79,7 +76,6 @@ def __init__(
)

self._attr_entity_registry_enabled_default = default_enabled
self._attr_entity_registry_visible_default = default_visible

if self._switch_name == "snapshots":
self._icon = ICON_IMAGE_MULTIPLE
Expand Down
1 change: 0 additions & 1 deletion custom_components/frigate/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def __init__(
"""Construct a FrigateContainerUpdate."""
FrigateEntity.__init__(self, config_entry)
CoordinatorEntity.__init__(self, coordinator)
self._attr_entity_registry_visible_default = False

@property
def unique_id(self) -> str:
Expand Down
2 changes: 0 additions & 2 deletions tests/test_binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ async def test_binary_sensors_setup_correctly_in_registry(
TEST_BINARY_SENSOR_FRONT_DOOR_MOTION_ENTITY_ID,
TEST_BINARY_SENSOR_FRONT_DOOR_PERSON_OCCUPANCY_ENTITY_ID,
TEST_BINARY_SENSOR_STEPS_PERSON_OCCUPANCY_ENTITY_ID,
},
entities_hidden={
TEST_BINARY_SENSOR_FRONT_DOOR_ALL_OCCUPANCY_ENTITY_ID,
TEST_BINARY_SENSOR_STEPS_ALL_OCCUPANCY_ENTITY_ID,
},
Expand Down
6 changes: 4 additions & 2 deletions tests/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ async def test_cameras_setup_correctly_in_registry(
TEST_CAMERA_FRONT_DOOR_ENTITY_ID,
TEST_CAMERA_FRONT_DOOR_PERSON_ENTITY_ID,
},
entities_visible={TEST_CAMERA_FRONT_DOOR_ENTITY_ID},
entities_hidden={TEST_CAMERA_FRONT_DOOR_PERSON_ENTITY_ID},
entities_visible={
TEST_CAMERA_FRONT_DOOR_ENTITY_ID,
TEST_CAMERA_FRONT_DOOR_PERSON_ENTITY_ID,
},
)
2 changes: 1 addition & 1 deletion tests/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ async def test_sensors_setup_correctly_in_registry(
TEST_SENSOR_CPU1_INTFERENCE_SPEED_ENTITY_ID,
TEST_SENSOR_CPU2_INTFERENCE_SPEED_ENTITY_ID,
},
entities_hidden={
entities_visible={
TEST_SENSOR_STEPS_ALL_ENTITY_ID,
TEST_SENSOR_STEPS_PERSON_ENTITY_ID,
TEST_SENSOR_FRONT_DOOR_ALL_ENTITY_ID,
Expand Down
4 changes: 1 addition & 3 deletions tests/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ async def test_switches_setup_correctly_in_registry(
entities_visible={
TEST_SWITCH_FRONT_DOOR_SNAPSHOTS_ENTITY_ID,
TEST_SWITCH_FRONT_DOOR_RECORDINGS_ENTITY_ID,
},
entities_hidden={
TEST_SWITCH_FRONT_DOOR_DETECT_ENTITY_ID,
TEST_SWITCH_FRONT_DOOR_MOTION_ENTITY_ID,
}.union(DISABLED_SWITCH_ENTITY_IDS),
},
)
2 changes: 1 addition & 1 deletion tests/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,5 @@ async def test_update_sensor_setup_correctly_in_registry(
await test_entities_are_setup_correctly_in_registry(
hass,
entities_enabled={TEST_UPDATE_FRIGATE_CONTAINER_ENTITY_ID},
entities_hidden={TEST_UPDATE_FRIGATE_CONTAINER_ENTITY_ID},
entities_visible={TEST_UPDATE_FRIGATE_CONTAINER_ENTITY_ID},
)

0 comments on commit 52dae45

Please sign in to comment.