From 13e5722fc7bc7beed22ea49fd97d600033f23a39 Mon Sep 17 00:00:00 2001 From: Jezza34000 <57314417+Jezza34000@users.noreply.github.com> Date: Mon, 16 Dec 2024 06:31:08 +0100 Subject: [PATCH] :memo: update README.md --- README.md | 58 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index ab1cba1..9e3b497 100644 --- a/README.md +++ b/README.md @@ -42,38 +42,42 @@ pip install pypetkitapi ## Usage Example: ```python -import asyncio -import logging +import aiohttp from pypetkitapi.client import PetKitClient +from pypetkitapi.command import DeviceCommand, FeederCommand, LBCommand, LBAction, LitterCommand logging.basicConfig(level=logging.DEBUG) - async def main(): - client = PetKitClient( - username="username", # Your PetKit account username or id - password="password", # Your PetKit account password - region="France", # Your region or country code (e.g. FR, US, etc.) - timezone="Europe/Paris", # Your timezone - ) - - # To get the account and devices data attached to the account - await client.get_devices_data() - - # Read the account data - print(client.account_data) - - # Read the devices data - print(client.device_list) - - # Send command to the devices - ### Example 1 : Turn on the indicator light - ### Device_ID, Command, Payload - await client.send_api_request(012346789, DeviceCommand.UPDATE_SETTING, {"lightMode": 1}) - - ### Example 2 : Feed the pet - ### Device_ID, Command, Payload - await client.send_api_request(0123467, FeederCommand.MANUAL_FEED, {"amount": 1}) + async with aiohttp.ClientSession() as session: + client = PetKitClient( + username="username", # Your PetKit account username or id + password="password", # Your PetKit account password + region="FR", # Your region or country code (e.g. FR, US, etc.) + timezone="Europe/Paris", # Your timezone + session=session, + ) + + await client.get_devices_data() + + # Read the account data + print(client.account_data) + + # Read the devices data + print(client.petkit_entities) + + # Send command to the devices + ### Example 1 : Turn on the indicator light + ### Device_ID, Command, Payload + await client.send_api_request(123456789, DeviceCommand.UPDATE_SETTING, {"lightMode": 1}) + + ### Example 2 : Feed the pet + ### Device_ID, Command, Payload + await client.send_api_request(123456789, FeederCommand.MANUAL_FEED, {"amount": 1}) + + ### Example 3 : Start the cleaning process + ### Device_ID, Command, Payload + await client.send_api_request(123456789, LitterCommand.CONTROL_DEVICE, {LBAction.START: LBCommand.CLEANING}) if __name__ == "__main__":