百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
M

magicblue

> 编程语言
开源

非官方的 Python API,可通过蓝牙控制 Magic Blue 灯泡

100 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

非官方的 Python API,可通过蓝牙控制 Magic Blue 灯泡

MagicBlue - Cheap bluetooth bulbs

The Magic Bulb is, as far as I know, the cheapest bluetooth RGB light bulb on the market : you can get it for as low as ~8€/9$ on sites like Gearbest. It works pretty good and comes with mobile apps.

Unfortunately I haven't found any API or documentation for it, which is why I started this project.

There are multiple versions of the bulb, some of them may need development to be compatible with this project. If you have a different bulb version you can try to sniff bluetooth communications. Reverse-engineering information and pull requests are more than welcome

Bulb Version

v6
v7
v8
v9
v10




Status
☑️
☑️
☑️

☑️
☑️

Installation

HomeAssistant

If you want to use this project with HomeAssistant you'll need to install magicblue as described below then use the component available here: https://github.com/Betree/homeassistant-magicblue

MagicBlue is not compatible with Windows.

Linux

You must use python 3+ and have a proper Bluetooth 4.0 interface installed on your machine.

  • Prerequisite

    • Debian: sudo apt-get install libglib2.0-dev
    • Fedora: sudo dnf install glib2-devel
  • Install

    sudo pip3 install magicblue

    Library needs elevated permissions to use Bluetooth features. You can either run as root (required for magicblueshell), or give hcitool special capabilities (see this link)

Known errors

  • Bluepy not compiled (very common)

If you get an error like No such file or directory: '/usr/local/lib/python3.4/dist-packages/bluepy/bluepy-helper' or ERROR:magicblue.magicblueshell:Unexpected error with command "ls": Helper exited: this is a known bug in bluepy that sometimes doesn't get compiled when installed from Pypi. You can fix it by compiling the helper yourself : Go to the lib folder (usually /usr/local/lib/python3.5/dist-packages/bluepy-1.1.2-py3.5.egg/bluepy/ but could be different, especially if you're using a virtual env) and run sudo make (make should be enought for a virtual env).

More info: https://github.com/IanHarvey/bluepy/issues/158

  • Other errors

If you run into problems during devices listing or connect, try to follow this procedure to ensure your Bluetooth interface works correctly : How to use manually with Gatttool page

Usage

Python API

Check the API documentation

From shell

Script must be run as root.

You can always specify which bluetooth adapter (default: hci0) you want to use by specifying it with the -a option.

Using the interactive shell

Just launch magicblueshell as root user :

…

Passing command as an option

Script can also be used by command line (for example to include it in custom shell scripts):

…

So if you want to change the color of bulb with mac address "C7:17:1D:43:39:03", just run :

sudo magicblueshell -c 'set_color red' -m C7:17:1D:43:39:03

Contributing

To contribute to this repo, start with CONTRIBUTING.md then check open issues

The protocol isn't fully retro-engineered but Characteristics list page and How to use manually with Gatttool page should give you enough details to start working on your own implementation if you need to port this for another language / platform. On the research/bluetooth branch you'll also find capture of bluetooth packets exchanged between Android and the bulb (open hci_capture.log with Wireshark).

Issues· 23 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Pythonblebluetoothbulbiot

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言