Skip to main content

Lantern

Lantern is a library that allows for control of Yongnuo YN-series Bluetooth-enabled video lights via Python.

Currently, Lantern supports the following models:

Lantern has been tested on the following operating system(s):

  • Ubuntu 16.10

The protocol for communicating with the lights was reverse-engineered during a YouTube livestream: Reverse Engineering the Yongnuo YN 360 Bluetooth Protocol. The author uses the lights for studio lighting, and will be using the library in automation tools to ensure that each scene is properly lit.

Installation

Lantern requires bluepy – an wrapper around the BTLE portions of Linux's official Bluetooth protocol stack, BlueZ. Although the bluepy installation usually goes smoothly, you may encounter issues. It is recommended that you visit the bluepy project page to review their installation instructions.

Once you've got bluepy's dependencies installed, you can run the following command from your virtual environment:

$ pip install yn-lantern

NOTE: Lantern was written for Python 3, and has not been tested (and will most likely not work) in Python 2.x.

Getting Started

Getting started with Lantern is simple. Once you've installed the library using the steps provided above, you may import and use Lantern in your code. Please keep in mind that, on some systems, root privileges will be required to manage the bluetooth interface.

Lantern will attempt to render color temperatures from 1,000 to 40,000 kelvin. Color temperatures between 3,200 and 5,500 kelvin will be rendered using high-intensity, high-CRI LEDs when possible.

from lantern import Light

for light in Light.discover():
    # connect to the light
    light.connect()
    # set the color temperature of the light
    light.color_temperature = 4800
    # set the output of the light to 50% intensity
    light.intensity = 0.5
    # once we're done, disconnect
    light.disconnect()

For some types of lights (specifically, the YN-360), RGB colors can be rendered. In the following example, we connect to a specific light, and render RGB colors in two ways, pausing two seconds between each change.

import time

from lantern import Light

l = Light("e8:53:aa:45:db:c6")
l.connect()

# set an RGB color using a packed hex value
l.color = 0xFF9900
# sleep two seconds, as promised
time.sleep(2)
# set red, green, and blue components of the color individually
l.color = (0xff, 0x99, 0x00)

l.disconnect()

Contributing

Please fork and open a PR to contribute. Feel free to submit issues if you run into issues. I'll do my best to help.

License

This project is licensed under the MIT License, and is Copyright 2017 Kenneth Keiter.

Metadata

Release files for yn-lantern 1.1.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 yn-lantern 1.1.0
File Size Uploaded Provenance Actions
yn-lantern-1.1.0.tar.gz 6.0 kB Without provenance Details for yn-lantern-1.1.0.tar.gz

Release files / yn-lantern-1.1.0.tar.gz

Download URL yn-lantern-1.1.0.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b4a3273b57daa384dd7adacb9acad572482a5a82fec06ad7d5fa2e083435c88d
BLAKE2b-256 checksum
How to use checksums
7f085da030aba5131f3791ab1720694af5d4dfbd6815cd6e81a9243e1cf47777
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.3

Security for yn-lantern 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

1 release file No provenance

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