-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from brg468/valve-support
Smart Hose Timer Support
- Loading branch information
Showing
10 changed files
with
672 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
"""Program module for the smart hose timer.""" | ||
|
||
from rachiopy.rachioobject import RachioObject | ||
|
||
|
||
class Program(RachioObject): | ||
"""Program class for the smart hose timer.""" | ||
|
||
def list_programs(self, valve_id: str): | ||
"""Retreive the list of programs (schedules) for a valve. | ||
For more info of the content in the response see: | ||
https://rachio.readme.io/docs/programservice_listprograms | ||
:param valve_id: Valve's unique id | ||
:type valve_id: str | ||
:return: The return value is a tuple of (response, content), the first | ||
being and instance of the httplib2.Response class, the second | ||
being a string that contains the response entity body. | ||
:rtype: tuple | ||
""" | ||
path = f"program/listPrograms/{valve_id}" | ||
return self.valve_get_request(path) | ||
|
||
def get_program(self, program_id: str): | ||
"""Retreive the information for a specific program. | ||
For more info of the content in the response see: | ||
https://rachio.readme.io/docs/programservice_getprogram | ||
:param program_id: Program's unique id | ||
:type program_id: str | ||
:return: The return value is a tuple of (response, content), the first | ||
being and instance of the httplib2.Response class, the second | ||
being a string that contains the response entity body (Python | ||
object if it contains JSON). | ||
:rtype: tuple | ||
""" | ||
path = f"program/getProgram/{program_id}" | ||
return self.valve_get_request(path) | ||
|
||
def create_skip_overrides(self, program_id: str, timestamp: str): | ||
"""Create manual skips for the specific program run time. | ||
You can retrieve the runtimes from SummaryService.getValveDayViews | ||
For more info of the content in the response see: | ||
https://rachio.readme.io/docs/programservice_createskipoverrides | ||
:param program_id: Program's unique id | ||
:type program_id: str | ||
:param timestamp: Timestamp of the run to skip | ||
:type timestamp: timestamp | ||
:return: The return value is a tuple of (response, content), the first | ||
being and instance of the httplib2.Response class, the second | ||
being a string that contains the response entity body (Python | ||
object if it contains JSON). | ||
:rtype: tuple | ||
""" | ||
payload = {"programId": program_id, "timestamp": timestamp} | ||
return self.valve_post_request("program/createSkipOverrides", payload) | ||
|
||
def delete_skip_overrides(self, program_id: str, timestamp: str): | ||
"""Cancel program skips for the specified program run time. | ||
You can retrieve upcoming skips from SummaryService.getValveDayViews | ||
For more info of the content in the response see: | ||
https://rachio.readme.io/docs/programservice_deleteskipoverrides | ||
:param program_id: Program's unique id | ||
:type program_id: str | ||
:param timestamp: Timestamp of the run skip to delete | ||
:type timestamp: timestamp | ||
:return: The return value is a tuple of (response, content), the first | ||
being and instance of the httplib2.Response class, the second | ||
being a string that contains the response entity body (Python | ||
object if it contains JSON). | ||
:rtype: tuple | ||
""" | ||
payload = {"programId": program_id, "timestamp": timestamp} | ||
return self.valve_post_request("program/deleteSkipOverrides", payload) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Smart Hose Timer scheudle summary calls.""" | ||
|
||
from rachiopy.rachioobject import RachioObject | ||
|
||
|
||
class SummaryServce(RachioObject): | ||
"""Scheudle summary class.""" | ||
|
||
def get_valve_day_views(self, base_id: str, start, end): | ||
"""List historical and upcoming valve runs and skips. | ||
For more info of the content in the response see: | ||
https://rachio.readme.io/docs/summaryservice_getvalvedayviews | ||
:param base_id: Base's unique id | ||
:type dev_id: str | ||
:param start: Start date | ||
:type start: Object[] | ||
:param end: End date | ||
:type end: Object[] | ||
:return: The return value is a tuple of (response, content), the first | ||
being and instance of the httplib2.Response class, the second | ||
being a string that contains the response entity body. | ||
:rtype: tuple | ||
""" | ||
payload = { | ||
"resourceId": {"baseStationId": base_id}, | ||
"start": start, | ||
"end": end, | ||
} | ||
return self.valve_post_request("summary/getValveDayViews", payload) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
"""Valve Service.""" | ||
|
||
from rachiopy.rachioobject import RachioObject | ||
|
||
|
||
class Valve(RachioObject): | ||
"""Valve class for smart hose timer.""" | ||
|
||
def get_base_station(self, base_id: str): | ||
"""Retreive the information for a specific base station. | ||
For more info of the content in the response see: | ||
https://rachio.readme.io/docs/valveservice_getbasestation | ||
:param base_id: Base station's unique id | ||
:type user_id: str | ||
:return: The return value is a tuple of (response, content), the first | ||
being and instance of the httplib2.Response class, the second | ||
being a string that contains the response entity body (Python | ||
object if it contains JSON). | ||
:rtype: tuple | ||
""" | ||
path = f"valve/getBaseStation/{base_id}" | ||
return self.valve_get_request(path) | ||
|
||
def get_valve(self, valve_id: str): | ||
"""Retrieve the information for a specific smart valve. | ||
For more info of the content in the response see: | ||
https://rachio.readme.io/docs/valveservice_getvalve | ||
:param valve_id: Valve's unique id | ||
:type user_id: str | ||
:return: The return value is a tuple of (response, content), the first | ||
being and instance of the httplib2.Response class, the second | ||
being a string that contains the response entity body (Python | ||
object if it contains JSON). | ||
:rtype: tuple | ||
""" | ||
path = f"valve/getValve/{valve_id}" | ||
return self.valve_get_request(path) | ||
|
||
def list_base_stations(self, user_id: str): | ||
"""Retrieve all base stations for a given user ID. | ||
For more info of the content in the response see: | ||
https://rachio.readme.io/docs/valveservice_listbasestations | ||
:param user_id: Person's unique id | ||
:type user_id: str | ||
:return: The return value is a tuple of (response, content), the first | ||
being and instance of the httplib2.Response class, the second | ||
being a string that contains the response entity body (Python | ||
object if it contains JSON). | ||
:rtype: tuple | ||
""" | ||
path = f"valve/listBaseStations/{user_id}" | ||
return self.valve_get_request(path) | ||
|
||
def list_valves(self, base_id: str): | ||
"""Retreive all valves on a given base station. | ||
For more info of the content in the response see: | ||
https://rachio.readme.io/docs/valveservice_listvalves | ||
:param base_id: Base station's unique id | ||
:type user_id: str | ||
:return: The return value is a tuple of (response, content), the first | ||
being and instance of the httplib2.Response class, the second | ||
being a string that contains the response entity body (Python | ||
object if it contains JSON). | ||
:rtype: tuple | ||
""" | ||
path = f"valve/listValves/{base_id}" | ||
return self.valve_get_request(path) | ||
|
||
def set_default_runtime(self, valve_id: str, duration: int): | ||
"""Set the runtime for a valve when the button is pressed. | ||
For more info of the content in the response see: | ||
https://rachio.readme.io/docs/valveservice_setdefaultruntime | ||
:param valve_id: Valve's unique id | ||
:type user_id: str | ||
:param duration: Duration in seconds | ||
:type duration: int | ||
:return: The return value is a tuple of (response, content), the first | ||
being and instance of the httplib2.Response class, the second | ||
being a string that contains the response entity body (Python | ||
object if it contains JSON). | ||
:rtype: tuple | ||
""" | ||
payload = {"valveId": valve_id, "defaultRuntimeSeconds": duration} | ||
return self.valve_put_request("valve/setDefaultRuntime", payload) | ||
|
||
def start_watering(self, valve_id: str, duration: int): | ||
"""Start a valve. | ||
For more info of the content in the response see: | ||
https://rachio.readme.io/docs/valveservice_startwatering | ||
:param valve_id: Valve's unique id | ||
:type user_id: str | ||
:param duration: Duration in seconds | ||
:type duration: int | ||
:return: The return value is a tuple of (response, content), the first | ||
being and instance of the httplib2.Response class, the second | ||
being a string that contains the response entity body (Python | ||
object if it contains JSON). | ||
:rtype: tuple | ||
""" | ||
assert 0 <= duration <= 86400, "duration must be in range 0-86400" | ||
payload = {"valveId": valve_id, "durationSeconds": duration} | ||
return self.valve_put_request("valve/startWatering", payload) | ||
|
||
def stop_watering(self, valve_id: str): | ||
"""Stop a valve. | ||
For more info of the content in the response see: | ||
https://rachio.readme.io/docs/valveservice_stopwatering | ||
:param valve_id: Valve's unique id | ||
:type user_id: str | ||
:return: The return value is a tuple of (response, content), the first | ||
being and instance of the httplib2.Response class, the second | ||
being a string that contains the response entity body (Python | ||
object if it contains JSON). | ||
:rtype: tuple | ||
""" | ||
payload = {"valveId": valve_id} | ||
return self.valve_put_request("valve/stopWatering", payload) |
This file contains 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
Oops, something went wrong.