EQ3蓝牙恒温器支持库
项目描述
python-eq3bt
Python库和命令行工具,用于EQ3蓝牙智能恒温器,使用bleak(默认)、bluepy或gattlib进行BTLE通信。
功能
- 读取设备状态:锁定、低电量、阀门状态、窗户开启、目标温度、活动模式
- 写入设置:目标温度、自动模式预设、温度偏移量
- 设置活动模式:自动、手动、增强、离家
- 读取设备序列号和固件版本
- 在较新的固件版本中读取预设和温度偏移量。
不支持(尚未)
- 没有易于使用的界面来设置日程。
安装
pip install python-eq3bt
命令行使用
要测试所有可用功能,可以使用utils中的cli工具
$ eq3cli --help
Usage: eq3cli [OPTIONS] COMMAND [ARGS]...
Tool to query and modify the state of EQ3 BT smart thermostat.
Options:
--mac TEXT [required]
--interface TEXT
--debug / --normal
--backend [bleak|bluepy|gattlib]
--help Show this message and exit.
Commands:
away Enables or disables the away mode.
boost Gets or sets the boost mode.
device Displays basic device information.
locked Gets or sets the lock.
low-battery Gets the low battery status.
mode Gets or sets the active mode.
offset Sets the temperature offset [-3,5 3,5]
presets Sets the preset temperatures for auto mode.
schedule Gets the schedule from the thermostat.
state Prints out all available information.
temp Gets or sets the target temperature.
valve-state Gets the state of the valve.
window-open Gets and sets the window open settings.
EQ3_MAC环境变量可以用来定义mac,以避免输入
export EQ3_MAC=XX:XX
如果没有参数,将打印设备的当前状态。
$ eq3cli
[00:1A:22:XX:XX:XX] Target 17.0 (mode: auto dst, away: no)
Locked: False
Batter low: False
Window open: False
Window open temp: 12.0
Window open time: 0:15:00
Boost: False
Current target temp: 17.0
Current comfort temp: 20.0
Current eco temp: 17.0
Current mode: auto dst locked
Valve: 0
获取和设置值。
$ eq3cli temp
Current target temp: 17.0
eq3cli temp --target 20
Current target temp: 17.0
Setting target temp: 20.0
配对
如果您有固件版本为1.20+的恒温器,可能需要进行配对。以下是一个简单的配对步骤。
Press and hold wheel on thermostat until Pair will be displayed. Remember or write it.
$ sudo bluetoothctl
[bluetooth]# power on
[bluetooth]# agent on
[bluetooth]# default-agent
[bluetooth]# scan on
[bluetooth]# scan off
[bluetooth]# pair 00:1A:22:06:A7:83
[agent] Enter passkey (number in 0-999999): <enter pin>
[bluetooth]# trust 00:1A:22:06:A7:83
[bluetooth]# disconnect 00:1A:22:06:A7:83
[bluetooth]# exit
Optional steps:
[bluetooth]# devices - to list all bluetooth devices
[bluetooth]# info 00:1A:22:06:A7:83
Device 00:1A:22:06:A7:83 (public)
Name: CC-RT-BLE
Alias: CC-RT-BLE
Paired: yes
Trusted: yes
Blocked: no
Connected: no
LegacyPairing: no
UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
UUID: Device Information (0000180a-0000-1000-8000-00805f9b34fb)
UUID: Vendor specific (3e135142-654f-9090-134a-a6ff5bb77046)
UUID: Vendor specific (9e5d1e47-5c13-43a0-8635-82ad38a1386f)
ManufacturerData Key: 0x0000
ManufacturerData Value:
00 00 00 00 00 00 00 00 00 .........
请注意,有时如果您配对设备,那么移动应用程序(calor BT)可能无法与恒温器连接,反之亦然。
库使用
from eq3bt import Thermostat
thermostat = Thermostat('AB:CD:EF:12:23:45')
thermostat.update() # fetches data from the thermostat
print(thermostat)
获取日程
日程按日查询,可以通过 schedule
属性访问缓存信息。
from eq3bt import Thermostat
thermostat = Thermostat('AB:CD:EF:12:34:45')
thermostat.query_schedule(0)
print(thermostat.schedule)
设置日程
'base_temp' 和 'next_change_at' 参数定义了该日第一时段(从午夜到 next_change_at)。
日程可以按日设置,如下所示
from datetime import time
from eq3bt import Thermostat
from eq3bt import HOUR_24_PLACEHOLDER as END_OF_DAY
thermostat = Thermostat('12:34:56:78:9A:BC')
thermostat.set_schedule(
dict(
cmd="write",
day="sun",
base_temp=18,
next_change_at=time(8, 0),
hours=[
dict(target_temp=23, next_change_at=time(20, 0)),
dict(target_temp=18, next_change_at=END_OF_DAY),
dict(target_temp=23, next_change_at=END_OF_DAY),
dict(target_temp=23, next_change_at=END_OF_DAY),
dict(target_temp=23, next_change_at=END_OF_DAY),
dict(target_temp=23, next_change_at=END_OF_DAY)
]
)
)
贡献
请随时提交 pull 请求以改进库!
本项目使用 github actions 通过 black、isort、flake8 和 mypy 等工具强制执行代码格式化。您可以通过执行 pre-commit run -a
或使用 tox
(它还会运行测试套件)来在本地运行这些检查。
历史
该库是 Markus Peter 的 bluepy_devices(https://github.com/bimbar/bluepy_devices.git)的简化版,支持更多功能和更健壮的设备处理。
项目详情
下载文件
下载适用于您平台的项目文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。
源分发
python-eq3bt-0.2.tar.gz (18.8 kB 查看哈希值)
构建分发
python_eq3bt-0.2-py3-none-any.whl (20.2 kB 查看哈希值)
关闭
python-eq3bt-0.2.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | af23b82dde1742bf5448c511bdbdb5488c2285985037f975b3f87bec662712dd |
|
MD5 | 7657f552c8867fa8ade01466025b2a5e |
|
BLAKE2b-256 | 05f1e460cedabefdc29f8e30dd676e395eba9764080178e96b478084f42c3099 |
关闭
python_eq3bt-0.2-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 07dcb71dcde100b5e37c42575c0f05bfbf8e2e5d2dc33e4b2b566256fbf6bc41 |
|
MD5 | d4b60378c9c28d155945525562898020 |
|
BLAKE2b-256 | 7817529aa41e9ac5fb1bc90a907913ae2bef1ce9df487d5e6aee574f27b92e00 |