Skip to content

Commit

Permalink
add water sensors to get all devices function
Browse files Browse the repository at this point in the history
  • Loading branch information
Leggin committed Dec 8, 2024
1 parent 790a315 commit d68d5df
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/dirigera/hub/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(
self.api_base_url = f"https://{ip_address}:{port}/{api_version}"
self.websocket_base_url = f"wss://{ip_address}:{port}/{api_version}"
self.token = token
self.wsapp : Any = None
self.wsapp: Any = None

def headers(self) -> Dict[str, Any]:
return {"Authorization": f"Bearer {self.token}"}
Expand Down Expand Up @@ -348,8 +348,12 @@ def get_water_sensors(self) -> List[WaterSensor]:
Fetches all water sensors registered in the Hub
"""
devices = self.get("/devices")
water_sensors = list(filter(lambda x: x["deviceType"] == "waterSensor", devices))
return [dict_to_water_sensor(water_sensor, self) for water_sensor in water_sensors]
water_sensors = list(
filter(lambda x: x["deviceType"] == "waterSensor", devices)
)
return [
dict_to_water_sensor(water_sensor, self) for water_sensor in water_sensors
]

def get_water_sensor_by_id(self, id_: str) -> WaterSensor:
"""
Expand All @@ -374,6 +378,7 @@ def get_all_devices(self) -> List[Device]:
devices.extend(self.get_motion_sensors())
devices.extend(self.get_open_close_sensors())
devices.extend(self.get_outlets())
devices.extend(self.get_water_sensors())

return devices

Expand Down

0 comments on commit d68d5df

Please sign in to comment.