You are browsing as a guest. Sign up (or log in) to start making projects!

40m 40s logged

Kasa (TP-Link) Support Added

The Edge-AI Home Monitoring System now supports TP-Link Kasa smart plugs/switches, using the python-kasa library’s async Discover API for device communication.

What’s New

  • New Kasa class that discovers a device by IP via Discover.discover_single() (with optional username/password for cloud-authenticated devices) and wraps turn_on / turn_off / execute_command behind the same asyncio.run() pattern already used for Daikin and the Tapo devices.
  • New /api/kasa endpoint, gated behind @auth.login_required like the rest of the device APIs.
  • Registered kasa in DEVICE_ENDPOINTS and wired it into create_device_action, so Kasa devices can already be used as automation actions from day one.
  • Added send_kasa and send_daikin helper functions alongside the other device senders, for consistency across the codebase.

Why This Matters

Kasa is one of the most common smart plug ecosystems out there, so this adds another affordable device family to the system without needing a proprietary hub — anything plugged into a Kasa switch can now be turned on/off from the dashboard or from an automation rule, the same way Tapo and Shelly devices already are.

Challenges

  • Ran into a syntax issue in async_connect: await self.device = Discover.discover_single(...) isn’t valid — assignment has to come first, i.e. self.device = await Discover.discover_single(...). Needs fixing before this can actually run.
  • handle_kasa currently points at a config path (/config/device_config.json) that doesn’t match the filename (devices_config.json) or the relative-path convention used by every other handler — needs to be corrected to "config/devices_config.json".
  • Same route also references data["Room"][room][dev_type][number][ip] with ip unquoted (a variable reference instead of the string key "ip"), which will throw a NameError rather than the intended KeyError.
  • emit_device_event still isn’t wired into the Kasa (or Shelly) handler, so — same as the other non-TV devices — Kasa state changes can’t yet act as automation triggers.

Next Steps

  • Fix the await/assignment order bug in Kasa.async_connect, the config path, and the unquoted "ip" key in /api/kasa before testing against a real device.
  • Wire emit_device_event into Kasa, Shelly, and the remaining handlers so any device can act as both an action and a trigger.
  • Once event emission is consistent across all device types, move on to energy monitoring for the Tapo smart plugs.
0
1

Comments 0

No comments yet. Be the first!