Skip to main content

pykuna

Python3 async library for interacting with the Kuna camera mobile API

Requirements: aiohttp, asyncio, async_timeout

Install pykuna with python3 -m pip install pykuna.

Usage

pykuna's main class is KunaAPI; create an API object, and authenticate it, like this:

from aiohttp import ClientSession
from pykuna import KunaAPI

websession = ClientSession()

kuna = KunaAPI(USERNAME, PASSWORD, websession)

await kuna.authenticate()

Where:

  • USERNAME is the email address you use for the Kuna app;
  • PASSWORD is your password for the Kuna app; and,
  • websession is an instance of aiohttp.ClientSession().

After authenticating, populate (or refresh) a dict of all cameras in the Kuna account (key = camera serial number, value = camera object) by calling the update() method on the API object:

await kuna.update()

Methods

The following methods are available on a camera device object in the KunaAPI.cameras dict; all are async and must be awaited:

  • update() - refresh only that camera's properties from the API.
  • get_thumbnail() - returns a camera snapshot as a jpeg image.
  • set_property(property=state) - sets a property of the device. Properties currently settable via pykuna are:
    • bulb_on (boolean) - set the lightbulb on (true) or off (false)
    • led_mask (boolean) - set the status led on the device on (true) or off (false)
    • volume (int) - set the speaker volume of the device (minimum 0, maximum 100)
  • light_on() - turn on the camera's light bulb
  • light_off() - turn off the camera's light bulb
  • enable_notifications() - enable Kuna app notifications for the camera
  • disable_notifications() - diable Kuna app notifications for the camera
  • get_recordings_by_time(timedelta) - returns a python-list of recording objects for the past datetime.timedelta time period.

example.py

An example script is provided to demonstrate the usage of pykuna; it prints a list of cameras associated with the Kuna account, and retrieves the currently-existing recordings for the camera, printing the timestamp of each recording and its associated download link.

python example.py USERNAME PASSWORD

Caveats

pykuna interacts with Kuna's (private) mobile device API, which could change at any time. And, without official documentation or terms of service, there's no way to know what type or rate of usage may result in your account being banned by Kuna. Use carefully!

pykuna does not implement timeouts; use asyncio_timeout in your client code to wrap calls to the API as needed.

pykuna was inspired by the investigative work of @loghound: https://github.com/loghound/kuna-camera-api, but does not yet implement all known endpoints; this project is primarily intended to interface Home Assistant with the Kuna API, and will be further developed with that goal in mind.

pykuna will hit v1.0.0 when it's ready for Home Assistant. Until then, pykuna's API may change at any time!

Contributing

Please open issues or pull requests.

Release files for pykuna 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pykuna 0.6.0
File Size Uploaded
pykuna-0.6.0.tar.gz 5.5 kB Details

Release files / pykuna-0.6.0.tar.gz

Download URL pykuna-0.6.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bb02d42d8e21ada21f3bab49f581f53fc122269342b8bdbe34b0bbbee8aba72f
BLAKE2b-256 checksum
How to use checksums
ef74b6ce1a422ff060f84431fa79bdcdf72581da6b04ec6b9637104d6c31b92c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.4

Release history Release notifications | RSS feed

This release

0.6.0 This release

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page