diff --git a/README.md b/README.md index 9e30dd1..15f4294 100644 --- a/README.md +++ b/README.md @@ -9,21 +9,24 @@ See the [github project](https://github.com/allenporter/pyrainbird). This is an example usage to get the current irrigation state for all available irrigation zones: -``` +```python +import asyncio import aiohttp from pyrainbird import async_client -async with aiohttp.ClientSession() as client: - controller: AsyncRainbirdController = async_client.CreateController( - client, - "192.168.1.1", - "password" - ) - zones = await controller.get_available_stations() - states = await controller.get_zone_states() - for zone in zones: - if zone in states.active_set: - print("Sprinkler zone {zone} is active") +async def main() -> None: + async with aiohttp.ClientSession() as client: + controller: async_client.AsyncRainbirdController = async_client.CreateController( + client, + "192.168.1.1", + "password" + ) + zones = await controller.get_available_stations() + states = await controller.get_zone_states() + for zone in zones.active_set: + print(f"Sprinkler zone {zone}: {"active" if zone in states.active_set else "inactive"}") + +asyncio.run(main()) ``` See [examples](examples/) for additional details on how to use the APIs and an example command diff --git a/examples/mitm_rainbird.py b/examples/mitm_rainbird.py index 904cd31..c993bf5 100644 --- a/examples/mitm_rainbird.py +++ b/examples/mitm_rainbird.py @@ -13,6 +13,7 @@ from mitmproxy import contentviews, flow, http import pyrainbird +import pyrainbird.encryption from pyrainbird import rainbird @@ -79,6 +80,7 @@ def render_priority( return 0 if content_type != "application/octet-stream": return 0 + assert isinstance(flow, http.HTTPFlow) if flow.request: if "/stick" in flow.request.path: return 1 diff --git a/pyrainbird/data.py b/pyrainbird/data.py index 61e00f8..9c75f58 100644 --- a/pyrainbird/data.py +++ b/pyrainbird/data.py @@ -79,10 +79,10 @@ class ModelAndVersion: model: int """The device model number hex code.""" - major: str + major: int """The major version string.""" - minor: str + minor: int """The minor version string.""" @property