Skip to main content

Controll bluetooth lamp from python

Project description

bt-lamp

This is a python lib for control your Bluetooth Low Energy (BLE) lamp.

Features

The lib offers the following functionality:

  • Turning the lamp on / off
  • Controlling lamp brightness
  • Controlling lamp temperature
  • Sending initial setup signal

Lamp compatibility

bt-lamp should work with at least some lamps (that are non-RGB, dimmable, cool/warm only) that use the following app

Lamps tested to work include

  • Natali Kovaltseva with BT support

OS

Lib tested on raspberry 2. Lib need sudo permissions

Hardware

Your bluetooth card needs to support at least Bluetooth v4.0 LE and have working drivers / firmware for Linux.

Working cards (not exhaustive):

Usage

You van use lib from command line or import as module. To install the module, run:

pip install bt_lamp

Comand line syntax

sudo -E env PATH=$PATH python -m bt_lamp command name [level] [log-level]

Available command:

  • setup connect to the lamp
  • on turn the lamp on
  • off turn the lamp off
  • cold <1..10> set cold brightness
  • warm <1..10> set warm brightness
  • dual <1..10> set dual brightness

level - lamp brightness, number between 1 and 10

Using as module

from bt_lamp import BtLamp

lamp = BtLamp("MY_LAMP")

# setup
lamp.setup()

# on
lamp.on()

# off
lamp.off()

# cold
lamp.cold(5)

# warm
lamp.warm(5)

# dual
lamp.dual(5)

Initial setup

Before you can control your lamp, you have to perform an initial setup so the lamp will remember a unique name that you specify.

To setup more than one lamp, setup each lamp individually by assigning a new name to each lamp.

To perform the initial setup:

  • Think up of a name. In this example we will use LAMP0.
  • Turn the lamp on using the power switch
  • Within a few seconds after powering the lamp on, send a setup signal from your device:
sudo -E env PATH=$PATH python -m bt_lamp setup LAMP0
  • If you see the lamp flashing, the connection is established

To reiterate sudo permissions are required to access the ble stack on modern linux

Project details


Download files

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

Source Distribution

bt_lamp-1.0.7.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

bt_lamp-1.0.7-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file bt_lamp-1.0.7.tar.gz.

File metadata

  • Download URL: bt_lamp-1.0.7.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for bt_lamp-1.0.7.tar.gz
Algorithm Hash digest
SHA256 a968d65c9cb3ed2e3ed612a2193be8a7a829a9def415a4b23091caeeb4b93cde
MD5 55adf0d793efcc0bcbed4f8bc805c8a8
BLAKE2b-256 df03e13c06ab1992b048e875ea2b76b1c9b20f16e8c6d31b4480f5d6289ae963

See more details on using hashes here.

File details

Details for the file bt_lamp-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: bt_lamp-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for bt_lamp-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c1cd5bd9f43702ec93452206c749f75c79dcd04ec3ead676d6a5e829ad264b4f
MD5 43de6a5395753157d9d49e6529c20b98
BLAKE2b-256 b40e1f9a34fada312e7cd5e2dcfec98fd0fc6b329eecb10a2d16b386916f3db4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page