Open
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the irrigation service to track real-time zone running status by querying the schedule_runs API. The changes include refactoring the _get_schedule_runs method to return raw API data and adding a new _update_running_status method that parses this data to update each zone's running state and remaining time.
- Adds
is_runningandremaining_timeattributes to theZoneclass to track real-time status - Refactors
_get_schedule_runsto return raw API response instead of simplified data - Implements
_update_running_statusto parse running schedules and update zone status - Converts string literals from double quotes to single quotes throughout (with some inconsistencies)
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 12 comments.
| File | Description |
|---|---|
| src/wyzeapy/services/irrigation_service.py | Adds zone running status tracking, updates Zone class with new attributes, adds _update_running_status method, and converts most string literals to single quotes |
| src/wyzeapy/services/base_service.py | Refactors _get_schedule_runs to create custom payload and signature, removes unused import, reorders methods, and updates quote style |
Comments suppressed due to low confidence (3)
src/wyzeapy/services/irrigation_service.py:242
- Variable total_remaining is not used.
total_remaining = int((end_time - now).total_seconds())
src/wyzeapy/services/irrigation_service.py:2
- Import of 'time' is not used.
import time
src/wyzeapy/services/irrigation_service.py:5
- Import of 'Optional' is not used.
from typing import Any, Dict, List, Optional
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Add Running Status Support for Irrigation Devices
Summary
This PR adds real-time running status detection for Wyze Sprinkler Controllers (irrigation devices). It introduces two new properties on
Zoneobjects:is_runningandremaining_time, which are automatically updated when callingIrrigationService.update().Motivation
Currently, the wyzeapy library provides static configuration for irrigation zones (names, durations, etc.) but doesn't expose whether a zone is actively watering or how much time remains. The Wyze API provides this information via the
/plugin/irrigation/schedule_runsendpoint, but it wasn't being utilized.This enhancement enables Home Assistant integrations and other applications to:
Changes Made
1. Zone Class Enhancement (
irrigation_service.py)Added two new properties to the
Zoneclass:2. New Public Method (
irrigation_service.py)Added
get_schedule_runs()method to retrieve schedule history and current running status:3. Internal Status Update Method (
irrigation_service.py)Added
_update_running_status()to parse schedule_runs response and update zone properties:4. Integration into Update Flow (
irrigation_service.py)Modified
IrrigationService.update()to automatically fetch running status:5. Base Service Method (
base_service.py)Added
_get_schedule_runs()method to handle the API call:API Endpoint Used
This implementation uses the existing Wyze API endpoint:
https://wyze-lockwood-service.wyzecam.com/plugin/irrigation/schedule_runsdevice_id,limit,nonceschedule_stateof "past", "running", or "upcoming"Testing
Tested with a live Wyze Sprinkler Controller (model BS_WK1):
Test 1: No Zones Running
Test 2: Zone Actively Running
Test 3: Remaining Time Countdown
Backward Compatibility
✅ Fully backward compatible
Falseand0Error Handling
Performance Impact
update()callDependencies
No new dependencies added. Uses existing:
datetime(standard library)timezone(standard library)Future Enhancements
Potential follow-ups (not included in this PR):
next_scheduled_runproperty toIrrigationclassget_schedules()method for full schedule configurationDocumentation
Added docstrings for all new methods following existing patterns.
Checklist
Example Usage
Related Issues
Addresses the need for real-time irrigation monitoring in home automation scenarios. Enables features like:
Testing Device: Wyze Sprinkler Controller (BS_WK1)
Firmware Version: 1.0.11
Library Version: 0.5.30 (modified)