Skip to main content
https://badge.fury.io/py/carson-living-electric-boogaloo.svg https://github.com/lowlydba/python-carson-living/actions/workflows/ci.yml/badge.svg https://img.shields.io/badge/License-Apache%202.0-blue.svg https://img.shields.io/pypi/pyversions/carson-living-electric-boogaloo.svg

Python Carson Living is a library written in Python that exposes the carson.live devices as Python objects.

Disclaimer

Please use this library at your own risk and make sure that you do not violate the Terms of Service of Carson.

Getting started

Installation

Carson Living Python requires Python 3.11 or newer.

# Installing from PyPi
$ pip install carson-living-electric-boogaloo

# Installing latest development
$ pip install \
    git+https://github.com/lowlydba/python-carson-living@main

Initialize a Carson API object

# Initializing an API object
carson = Carson("account@email.com", 'your password')
print(carson.user)
# >> Martin
print(carson.token)
# >> ey...

You are also able to pass a valid JWT token during initialization which would prevent a login action as long as the token is valid:

# Initializing an API object with a valid token
carson = Carson("account@email.com", 'your password', 'ey....')
print(carson.token)
# >> Martin

Since Carson Living uses JWT token with very long validity, it is recommended to save the active token via carson.token, whenever one needs to reinitialize the API later on. The API library is robust to handle expired JWT tokens (and 401 handling), so no need to check before.

Carson entities

The library currently supports the following entities and actions.

  • User (carson.user): read

  • Building (carson.buildings): read

  • Doors (building.doors): read, open

  • Cameras (building.cameras): read, images, video

Door entities

Doors can be “buzzed” open via door.open()

# Open all Unit Doors of Main Building
for door in carson.first_building.doors:
    if door.is_unit_door:
        print('Opening Unit Door {}'.format(door.name))
        door.open()

Camera entities

Eagle Eye cameras can produce live images and videos but also allow access to passed recordings (see API). The API can download the image and video directly into a provided file object or just pass a generated url with an eagle_eye auth key A=c000..... Please note, that the url can only be accessed as long as the auth_key is valid. Therefore it may make sense to force the eagle eye api to refresh the auth key before generating a image or video url.

  • Directly save a live image:

for camera in building.cameras:
    with open('image_{}.jpeg'.format(camera.entity_id), 'wb') as file:
        camera.get_image(file)
  • Directly save a live video of 10s:

for camera in building.cameras:
    with open('video_{}.flv'.format(camera.entity_id), 'wb') as file:
        camera.get_video(file, timedelta(seconds=10))
  • Directly download a image from a timestamp:

three_hours_ago = datetime.utcnow() - timedelta(hours=3)
# download all images from 3 hours ago
for camera in building.cameras:
    with open('image_{}.jpeg'.format(camera.entity_id), 'wb') as file:
        camera.get_image(file, three_hours_ago)
  • Directly download a recorded video from a timestamp:

three_days_ago = datetime.utcnow() - timedelta(days=3)
# download all videos from 3 days ago
for cam in building.cameras:
    with open('video_{}.flv'.format(cam.entity_id), 'wb') as file:
        cam.get_video(file, timedelta(seconds=5), three_days_ago)
  • The Carson API is also able to produce authenticated URLs that can be handled externally. Please not, that the auth_key has a limited lifetime. Therefore it makes sense to update the auth_key manually before retrieving predefined URLs. Note, the Eagle Eye API in Carson is associated with a building, so it is sufficient to update it once for all cameras in the same building. The function signature of the the _url function is identical to the previous ones (minus the file object).

# Update Session Auth Key of Eagle Eye once in a while if using
# generated authenticated URLs.
# Note, this is not needed for get_image() or get_video()
building.eagleeye_api.update_session_auth_key()
for cam in building.cameras:
    img_url = cam.get_image_url(three_days_ago)
    print(img_url)
    # >> https://cXXX.eagleeyenetworks.com/asset/prev/image.jpeg?id=c0&timestamp=20200122211442.575&asset_class=pre&A=c000~...
    response = requests.get(img_url)
    with open('image_{}_with_url.jpeg'.format(cam.entity_id), 'wb') as file:
        file.write(response.content)
    # do only 1 cam.
    break

Use cam.get_video_url() the same way.

CLI Tool

Checkout ./scripts/carsoncli.py for further API implementation examples.

Development Notes

Code Documentation

The code follow the Google Python Styleguide for docstring.

Git Branching Strategy

This project uses gitflow as a git branching model.

Open Items

The following is not supported by the API yet and remains TODO.

  • Expose visitor functionality (/visitors)

  • Expose thread / messaging functionality (/threads)

  • Expose delivery functionality (/deliveries)

  • Expose dashboard functionality (/dashboard)

  • Expose service functionality (/service)

  • Integrate Twilio (twilio/access-token/)

  • Expand and extract EagleEye API (into separate project?).

Credits && Thanks

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

carson_living_electric_boogaloo-0.1.0.tar.gz (27.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

carson_living_electric_boogaloo-0.1.0-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file carson_living_electric_boogaloo-0.1.0.tar.gz.

File metadata

File hashes

Hashes for carson_living_electric_boogaloo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e14971ae192e1dd630d4e006ab9d7d046508393c2f1a95d2c06d14197dc3b2c4
MD5 af92980d8b222c05585862300ec01021
BLAKE2b-256 0586443d51426ee87a23d561bee0e8aa98189e2ce04bb1b14ada57d815585bf0

See more details on using hashes here.

Provenance

The following attestation bundles were made for carson_living_electric_boogaloo-0.1.0.tar.gz:

Publisher: release.yml on lowlydba/python-carson-living

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file carson_living_electric_boogaloo-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for carson_living_electric_boogaloo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bafe32263020faf5f9bd87d1644a8dc00669d42ac552abfcde2fceb84e670612
MD5 32ffeab55698e936494c742e58819f2b
BLAKE2b-256 57796aba40e672d1b43cad1291a5aacbed23f945700b2f2f4782728d894e7e94

See more details on using hashes here.

Provenance

The following attestation bundles were made for carson_living_electric_boogaloo-0.1.0-py3-none-any.whl:

Publisher: release.yml on lowlydba/python-carson-living

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.1

2 files

This release

0.1.0 This release

2 files

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