- Fork tapo crate to add missing schedule/timer APIs - Add get_countdown_rules, get_schedule_rules, get_next_event methods - New readings: countdown_active, countdown_remain, schedule_count, schedule_active_count, next_event_time - Add local compilation to build script alongside cross-compilation - Implement offline polling - device collection continues when server disconnects - Add more device readings: on_time, signal_level, rssi, runtime_today/month, energy_month Vendored tapo fork in tapo-fork/ with minimal changes to add schedule APIs.
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
"""P300 and P306 Example"""
|
|
|
|
import asyncio
|
|
import os
|
|
|
|
from tapo import ApiClient
|
|
|
|
|
|
async def main():
|
|
tapo_username = os.getenv("TAPO_USERNAME")
|
|
tapo_password = os.getenv("TAPO_PASSWORD")
|
|
ip_address = os.getenv("IP_ADDRESS")
|
|
|
|
client = ApiClient(tapo_username, tapo_password)
|
|
power_strip = await client.p300(ip_address)
|
|
|
|
device_info = await power_strip.get_device_info()
|
|
print(f"Device info: {device_info.to_dict()}")
|
|
|
|
print("Getting child devices...")
|
|
child_device_list = await power_strip.get_child_device_list()
|
|
print(f"Found {len(child_device_list)} plugs")
|
|
|
|
for index, child in enumerate(child_device_list):
|
|
print(f"=== ({index + 1}) {child.nickname} ===")
|
|
print(f"Device ID: {child.device_id}")
|
|
print(f"State: {child.device_on}")
|
|
|
|
plug = await power_strip.plug(device_id=child.device_id)
|
|
|
|
print("Turning device on...")
|
|
await plug.on()
|
|
|
|
print("Waiting 2 seconds...")
|
|
await asyncio.sleep(2)
|
|
|
|
print("Turning device off...")
|
|
await plug.off()
|
|
|
|
print("Waiting 2 seconds...")
|
|
await asyncio.sleep(2)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|