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 water sensors to get all devices function #106

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
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
Loading