Skip to content

Commit

Permalink
add function for fetching scenes by name (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leggin authored Dec 8, 2024
1 parent 1f9040c commit 91ed7a6
Showing 1 changed file with 10 additions and 0 deletions.
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

0 comments on commit 91ed7a6

Please sign in to comment.