Skip to content

Commit

Permalink
Only add camera objects to zones if that zone defines that object (#195)
Browse files Browse the repository at this point in the history
* Add check for each obj in each zone

* Fix typo

* Remove ds store

* Fix typo

* Fix indentations

* Handle case where objects are not explicityly defined for zone

* Use correct formatting

* Use .get() so it won't fail on null

* Fix formatting with pre-commit
  • Loading branch information
NickM-27 authored Jan 5, 2022
1 parent cea1083 commit 49805c7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion custom_components/frigate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@

_LOGGER: logging.Logger = logging.getLogger(__name__)


# Typing notes:
# - The HomeAssistant library does not provide usable type hints for custom
# components. Certain type checks (e.g. decorators and class inheritance) need
Expand Down Expand Up @@ -111,7 +112,11 @@ def get_cameras_zones_and_objects(config: dict[str, Any]) -> set[tuple[str, str]
zone_objects = set()
for cam_name, obj in camera_objects:
for zone_name in config["cameras"][cam_name]["zones"]:
zone_objects.add((zone_name, obj))
zone_name_objects = config["cameras"][cam_name]["zones"][zone_name].get(
"objects"
)
if not zone_name_objects or obj in zone_name_objects:
zone_objects.add((zone_name, obj))
return camera_objects.union(zone_objects)


Expand Down

0 comments on commit 49805c7

Please sign in to comment.