pydrawise.hybrid
pydrawise.hybrid
Client library for interacting with Hydrawise APIs.
This utilizes both the GraphQL and REST APIs.
HybridClient
HybridClient(auth: HybridAuth, app_id: str = DEFAULT_APP_ID, gql_client: Hydrawise | None = None, gql_throttle: Throttler | None = None, rest_throttle: Throttler | None = None)
Bases: HydrawiseBase
Client library that uses both the GraphQL and REST Hydrawise APIs.
Prefers the GraphQL API, but falls back to (and caches results from) the REST API when GraphQL requests are throttled. This is useful for applications that poll frequently and want to stay within Hydrawise's GraphQL rate limits.
Should be instantiated with a HybridAuth object that handles authentication and low-level transport for both APIs.
Initializes the client.
| Parameters: |
|
|---|
delete_zone_suspension
async
delete_zone_suspension(suspension: ZoneSuspension) -> None
Removes a specific zone suspension. Always uses the GraphQL API.
Useful when there are multiple suspensions for a zone in effect.
| Parameters: |
|
|---|
get_controller
async
get_controller(controller_id: int) -> Controller
Retrieves a single controller by its unique identifier.
Uses the GraphQL API while it has throttle budget; otherwise returns the cached controller.
| Parameters: |
|
|---|
get_controllers
async
get_controllers(fetch_zones: bool = True, fetch_sensors: bool = True) -> list[Controller]
Retrieves all controllers associated with the currently authenticated user.
Uses the GraphQL API while it has throttle budget, refreshing zones from the REST API otherwise. Results are cached and returned from the cache on subsequent calls once throttled.
| Parameters: |
|
|---|
get_sensors
async
get_sensors(controller: Controller) -> list[Sensor]
Retrieves sensors associated with the given controller.
Always uses the GraphQL API, throttled: once the GraphQL throttle is exhausted, the last result for this controller is returned instead, or ThrottledError is raised if there is none yet.
| Parameters: |
|
|---|
get_user
async
get_user(fetch_zones: bool = True) -> User
Retrieves the currently authenticated user.
Uses the GraphQL API while it has throttle budget, refreshing zones from the REST API otherwise.
| Parameters: |
|
|---|
get_water_flow_summary
async
get_water_flow_summary(controller: Controller, sensor: Sensor, start: datetime, end: datetime) -> SensorFlowSummary
Retrieves the water flow summary for a given sensor. Always uses the GraphQL API.
| Parameters: |
|
|---|
get_water_use_summary
async
get_water_use_summary(controller: Controller, start: datetime, end: datetime) -> ControllerWaterUseSummary
Calculate the water use for the given controller and time period.
Always uses the GraphQL API.
| Parameters: |
|
|---|
get_watering_report
async
get_watering_report(controller: Controller, start: datetime, end: datetime) -> list[WateringReportEntry]
Retrieves a watering report for the given controller and time period.
Always uses the GraphQL API.
| Parameters: |
|
|---|
get_zone
async
get_zone(zone_id: int) -> Zone
Retrieves a zone by its unique identifier.
Always uses the GraphQL API (the REST API has no way to fetch a single zone), throttled: once the GraphQL throttle is exhausted, the last result for this zone id is returned instead, or ThrottledError is raised if there is none yet.
| Parameters: |
|
|---|
get_zones
async
get_zones(controller: Controller) -> list[Zone]
Retrieves zones associated with the given controller.
Uses the GraphQL API while it has throttle budget, refreshing from the REST API otherwise.
| Parameters: |
|
|---|
resume_all_zones
async
resume_all_zones(controller: Controller) -> None
Resumes the schedule of all zones attached to the given controller.
Always uses the GraphQL API.
| Parameters: |
|
|---|
resume_zone
async
resume_zone(zone: Zone) -> None
Resumes a zone's schedule. Always uses the GraphQL API.
| Parameters: |
|
|---|
start_all_zones
async
start_all_zones(controller: Controller, mark_run_as_scheduled: bool = False, custom_run_duration: int = 0) -> None
Starts all zones attached to a controller. Always uses the GraphQL API.
| Parameters: |
|
|---|
start_zone
async
start_zone(zone: Zone, mark_run_as_scheduled: bool = False, custom_run_duration: int = 0) -> None
Starts a zone's run cycle. Always uses the GraphQL API.
| Parameters: |
|
|---|
stop_all_zones
async
stop_all_zones(controller: Controller) -> None
Stops all zones attached to a controller. Always uses the GraphQL API.
| Parameters: |
|
|---|
stop_zone
async
stop_zone(zone: Zone) -> None
Stops a zone. Always uses the GraphQL API.
| Parameters: |
|
|---|
suspend_all_zones
async
suspend_all_zones(controller: Controller, until: datetime) -> None
Suspends the schedule of all zones attached to a given controller.
Always uses the GraphQL API.
| Parameters: |
|
|---|
suspend_zone
async
suspend_zone(zone: Zone, until: datetime) -> None
Suspends a zone's schedule. Always uses the GraphQL API.
| Parameters: |
|
|---|