Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add function for fetching scenes by name #107

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/dirigera/hub/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,16 @@ def get_scene_by_id(self, scene_id: str) -> Scene:
data = self.get(f"/scenes/{scene_id}")
return dict_to_scene(data, self)

def get_scene_by_name(self, scene_name: str) -> Scene:
"""
Fetches all scenes and returns the first result that matches scene_name
"""
scenes = self.get_scenes()
scenes = list(filter(lambda x: x.info.name == scene_name, scenes))
if len(scenes) == 0:
raise AssertionError(f"No Scene found with name {scene_name}")
return scenes[0]

def get_water_sensors(self) -> List[WaterSensor]:
"""
Fetches all water sensors registered in the Hub
Expand Down
Loading