This commit is contained in:
darthsandmann
2022-11-29 19:10:30 +01:00
parent 9b39f1af50
commit c74c45998c
57 changed files with 3163 additions and 6 deletions

View File

@ -0,0 +1 @@
pip

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Markus Peter
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,230 @@
Metadata-Version: 2.1
Name: python-eq3bt
Version: 0.2
Summary: EQ3 bluetooth thermostat support library
Home-page: https://github.com/rytilahti/python-eq3bt
License: MIT
Author: Teemu R.
Author-email: tpr@iki.fi
Requires-Python: >=3.7,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Provides-Extra: bluepy
Provides-Extra: gattlib
Requires-Dist: bleak
Requires-Dist: bluepy (>=1.0.5); extra == "bluepy"
Requires-Dist: click
Requires-Dist: construct
Requires-Dist: gattlib; extra == "gattlib"
Project-URL: Repository, https://github.com/rytilahti/python-eq3bt
Description-Content-Type: text/markdown
# python-eq3bt
Python library and a command line tool for EQ3 Bluetooth smart thermostats, uses bleak (default), bluepy or gattlib for BTLE communication.
# Features
* Reading device status: locked, low battery, valve state, window open, target temperature, active mode
* Writing settings: target temperature, auto mode presets, temperature offset
* Setting the active mode: auto, manual, boost, away
* Reading the device serial number and firmware version
* Reading presets and temperature offset in more recent firmware versions.
## Not (yet) supported
* No easy-to-use interface for setting schedules.
# Installation
```bash
pip install python-eq3bt
```
# Command-line Usage
To test all available functionality a cli tool inside utils can be used:
```
$ 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 environment variable can be used to define mac to avoid typing it:
```bash
export EQ3_MAC=XX:XX
```
Without parameters current state of the device is printed out.
```bash
$ 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
```
Getting & setting values.
```bash
$ eq3cli temp
Current target temp: 17.0
eq3cli temp --target 20
Current target temp: 17.0
Setting target temp: 20.0
```
# Pairing
If you have thermostat with firmware version 1.20+ pairing may be needed. Below simple procedure to do that.
```
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 .........
```
Be aware that sometimes if you pair your device then mobile application (calor BT) can't connect with thermostat and vice versa.
# Library Usage
```
from eq3bt import Thermostat
thermostat = Thermostat('AB:CD:EF:12:23:45')
thermostat.update() # fetches data from the thermostat
print(thermostat)
```
<aside class="notice">
Notice: The device in question has to be disconnected from bluetoothd, since BTLE devices can only hold one connection at a time.
The library will try to connect to the device second time in case it wasn't successful in the first time,
which can happen if you are running other applications connecting to the same thermostat.
</aside>
## Fetching schedule
The schedule is queried per day basis and the cached information can be
accessed through `schedule` property..
```
from eq3bt import Thermostat
thermostat = Thermostat('AB:CD:EF:12:34:45')
thermostat.query_schedule(0)
print(thermostat.schedule)
```
## Setting schedule
The 'base_temp' and 'next_change_at' paramater define the first period for that 'day' (the period from midnight up till next_change_at).
The schedule can be set on a per day basis like follows:
```
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)
]
)
)
```
# Contributing
Feel free to open pull requests to improve the library!
This project uses github actions to enforce code formatting using tools like black, isort, flake8, and mypy.
You can run these checks locally either by executing `pre-commit run -a` or using `tox` which also runs the test suite.
# History
This library is a simplified version of bluepy_devices from Markus Peter (https://github.com/bimbar/bluepy_devices.git) with support for more features and robuster device handling.

View File

@ -0,0 +1,25 @@
../../../bin/eq3cli,sha256=TFR4GGzCskn7h5eKh4qUtn2HO-VX7rl4O4VKAFMH92Y,215
CHANGELOG,sha256=FVxHhLou6OnfINd-OStO2tzYAjsalbowKDL61Fr9Z-Y,6002
eq3bt/__init__.py,sha256=fUKZ9G7dFcM5wEOIJdOUAUcyJBeDODsdeVCk2J-w3q0,189
eq3bt/__pycache__/__init__.cpython-310.pyc,,
eq3bt/__pycache__/bleakconnection.cpython-310.pyc,,
eq3bt/__pycache__/connection.cpython-310.pyc,,
eq3bt/__pycache__/eq3btsmart.cpython-310.pyc,,
eq3bt/__pycache__/eq3cli.cpython-310.pyc,,
eq3bt/__pycache__/gattlibconnection.cpython-310.pyc,,
eq3bt/__pycache__/structures.cpython-310.pyc,,
eq3bt/bleakconnection.py,sha256=E5QWp0fYUDR150zBB8xtY68cRThADXpEUei5F6hTCQo,4269
eq3bt/connection.py,sha256=j2E2Nugo3BeteHFY3uozfb_8YZxWB5Y1itNa_SGQtlk,3217
eq3bt/eq3btsmart.py,sha256=st-NMiIeuXOR6EYBESkKWyRnMfrFpzZq6b4P-sOy7Sk,15716
eq3bt/eq3cli.py,sha256=_YFvGT0XsHE3WdGW0jp1NaH_yrRnYDpvmwBJHPOm7io,6219
eq3bt/gattlibconnection.py,sha256=25s9pY0azzwEUfJsTRXcFs0SPeoOKwb2Tx4QUsL5w_g,3285
eq3bt/structures.py,sha256=rSFQ6eTYR-18A9WEcNPcBb2P8S-G-u9gx5jVhDIjgl0,4635
eq3bt/tests/__pycache__/test_thermostat.cpython-310.pyc,,
eq3bt/tests/test_thermostat.py,sha256=lDLCNvCNgVOJoa6JUEXvAtvfhkLZR2UJZh7_XvXGQbI,5381
python_eq3bt-0.2.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
python_eq3bt-0.2.dist-info/LICENSE,sha256=og5_OL0-NkYbkZwhvFpb4hR3EfM-0IXaore85BAkhLw,1079
python_eq3bt-0.2.dist-info/METADATA,sha256=gjGWD8CeJ_uZqr_JTfQd4wCfRErXhUxoLuJs5l8F3KA,6842
python_eq3bt-0.2.dist-info/RECORD,,
python_eq3bt-0.2.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
python_eq3bt-0.2.dist-info/WHEEL,sha256=DA86_h4QwwzGeRoz62o1svYt5kGEXpoUTuTtwzoTb30,83
python_eq3bt-0.2.dist-info/entry_points.txt,sha256=XClUgvSU6CSK_T1HCDmeMObxQ6wKPpxMjWlZe5TiELk,43

View File

@ -0,0 +1,4 @@
Wheel-Version: 1.0
Generator: poetry 1.0.8
Root-Is-Purelib: true
Tag: py3-none-any

View File

@ -0,0 +1,3 @@
[console_scripts]
eq3cli=eq3bt.eq3cli:cli