Python bindings for the e7-switcher C++ client
Project description
E7 Switcher Library
A cross-platform library for controlling Switcher smart home devices from both ESP32 and desktop platforms (Mac/Linux).
Features
- Control Switcher devices (switches, AC units, etc.)
- Cross-platform compatibility (ESP32 and Mac/Linux)
- Easy integration with PlatformIO and CMake projects
- Python bindings for easy integration with Python projects
Installation
Using PlatformIO
Add the library to your platformio.ini file:
lib_deps =
https://github.com/elhanan7/e7-switcher.git
Using CMake
There are multiple ways to include this library in your CMake project:
Option 1: Using FetchContent
include(FetchContent)
FetchContent_Declare(
e7-switcher
GIT_REPOSITORY https://github.com/elhanan7/e7-switcher.git
GIT_TAG main # or specific tag/commit
)
FetchContent_MakeAvailable(e7-switcher)
# Link with your target
target_link_libraries(your_target PRIVATE e7-switcher)
Option 2: Using find_package
First, install the library:
git clone https://github.com/elhanan7/e7-switcher.git
cd e7-switcher
mkdir build && cd build
cmake ..
make
sudo make install
Then in your CMakeLists.txt:
find_package(e7-switcher REQUIRED)
target_link_libraries(your_target PRIVATE e7-switcher::e7-switcher)
Using Python Bindings
The library provides Python bindings using pybind11, allowing you to control Switcher devices from Python.
Installation
# From the repository root
cd python
pip install .
# To specify a Python version
PYTHON_VERSION=3.9 pip install .
Alternatively, you can use the provided build script:
# From the repository root
cd python
./build_bindings.sh --install
# To specify a Python version
./build_bindings.sh --python-version 3.9 --install
You can also build the Python bindings using CMake:
mkdir build && cd build
cmake .. -DBUILD_PYTHON_BINDINGS=ON
make
Dependencies
For ESP32
- Arduino framework
- ArduinoJson (v7.0.4 or higher)
- zlib-PIO
For Desktop
- CMake 3.10 or higher
- C++17 compatible compiler
- OpenSSL development libraries
- nlohmann_json library (v3.11.2 or higher)
- zlib
For Python Bindings
- Python 3.6 or higher
- pybind11 (automatically fetched during build)
- pip and setuptools
Usage
Basic Usage
#include "e7-switcher/e7_switcher_client.h"
#include "e7-switcher/logger.h"
// Initialize the logger (debug messages are disabled by default)
e7_switcher::Logger::initialize(); // Default log level is INFO
auto& logger = e7_switcher::Logger::instance();
// To enable debug messages:
// e7_switcher::Logger::initialize(e7_switcher::LogLevel::DEBUG);
// Create client with your credentials
e7_switcher::E7SwitcherClient client{"your_account", "your_password"};
// List all devices
const auto& devices = client.list_devices();
for (const auto& device : devices) {
logger.infof("Device: %s (Type: %s)", device.name.c_str(), device.type.c_str());
}
// Control a switch
client.control_switch("Your Switch Name", "on"); // or "off"
// Get switch status
e7_switcher::SwitchStatus status = client.get_switch_status("Your Switch Name");
logger.infof("Switch status: %s", status.to_string().c_str());
// Control an AC unit
client.control_ac(
"Your AC Name",
"on", // "on" or "off"
e7_switcher::ACMode::COOL, // COOL, HEAT, FAN, DRY, AUTO
22, // temperature
e7_switcher::ACFanSpeed::FAN_MEDIUM, // FAN_LOW, FAN_MEDIUM, FAN_HIGH, FAN_AUTO
e7_switcher::ACSwing::SWING_ON // SWING_OFF, SWING_ON, SWING_HORIZONTAL, SWING_VERTICAL
);
Python Usage
from e7_switcher import E7SwitcherClient, ACMode, ACFanSpeed, ACSwing
# Create client with your credentials
client = E7SwitcherClient("your_account", "your_password")
# List all devices
devices = client.list_devices()
for device in devices:
print(f"Device: {device['name']}, Type: {device['type']}")
# Control a switch
client.control_switch("Your Switch Name", True) # Turn on
client.control_switch("Your Switch Name", False) # Turn off
# Get switch status
status = client.get_switch_status("Your Switch Name")
print(f"Switch is {'ON' if status['switch_state'] else 'OFF'}")
# Control an AC unit
client.control_ac(
"Your AC Name",
True, # Turn on
ACMode.COOL, # Mode
22, # Temperature
ACFanSpeed.FAN_MEDIUM, # Fan speed
ACSwing.SWING_ON # Swing
)
# Get AC status
status = client.get_ac_status("Your AC Name")
print(f"AC is {'ON' if status['power_status'] == 1 else 'OFF'}")
Examples
The library includes examples for both ESP32 desktop and Python platforms:
ESP32 Example
A simple example showing how to connect to WiFi and control Switcher devices from an ESP32.
cd examples/esp32_example
pio run -t upload
Desktop Example
A command-line example for controlling devices from desktop platforms.
cd examples/desktop_example
pio run
# Or with CMake:
mkdir build && cd build
cmake .. -DBUILD_EXAMPLES=ON
make
./e7-switcher-desktop-example status # Get device status
./e7-switcher-desktop-example on # Turn device on
./e7-switcher-desktop-example off # Turn device off
Python Example
A Python example for controlling devices using the Python bindings:
# First install the Python package
cd python
pip install .
# Then run the example
python examples/example_usage.py --account your_account --password your_password list
python examples/example_usage.py --account your_account --password your_password switch-status --device "Your Switch Name"
python examples/example_usage.py --account your_account --password your_password ac-on --device "Your AC Name" --mode cool --temp 22 --fan medium --swing on
License
This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file e7_switcher-1.0.6.tar.gz.
File metadata
- Download URL: e7_switcher-1.0.6.tar.gz
- Upload date:
- Size: 43.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fea9e496721f6e13ba796694d964e6b72e8890c33ceb816ba5b2fe74201d8f82
|
|
| MD5 |
bce445b523fd0c26611569d623d306a3
|
|
| BLAKE2b-256 |
efaecf1d0d240a32f36e4653e8fa538a405f39dca63d575a5ca924c713ccb15a
|
File details
Details for the file e7_switcher-1.0.6-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: e7_switcher-1.0.6-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 560.2 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b57f243893e3d913762907c6d2b90f31882a63d97a63c9a4548efcbe7e81e771
|
|
| MD5 |
105eb73986b16fa1e84d199bfb3aea2e
|
|
| BLAKE2b-256 |
b28aedfc28297b949884e541bb0806c27689c2005cef49c3b1a0931a21eb439d
|
File details
Details for the file e7_switcher-1.0.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: e7_switcher-1.0.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
341462751c256e72eb8d0869867111c8b2ce262776a406e38582bfa316302dc0
|
|
| MD5 |
123fd83026b188f04296368e7043d43d
|
|
| BLAKE2b-256 |
d02b688e98ac77adddfbd63e73bd397959f9feab8116decfb4ede0acbbd884a7
|
File details
Details for the file e7_switcher-1.0.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: e7_switcher-1.0.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bac823755c9f668dd9cb090733b61e490bcc80f9e909fe833473c13878dd34d
|
|
| MD5 |
5754d295128c385f838303e6294eb052
|
|
| BLAKE2b-256 |
db4affc6bff5a16b9e56e403be9d3e11981b2703e8c67c1ecec15e578c687bd8
|
File details
Details for the file e7_switcher-1.0.6-cp313-cp313-macosx_14_0_arm64.whl.
File metadata
- Download URL: e7_switcher-1.0.6-cp313-cp313-macosx_14_0_arm64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.13, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c79881083972a77ed00f9789b484173994be51668344ef749d606c4f25619a07
|
|
| MD5 |
56dd32215ae97dfa652bb22f972f3abc
|
|
| BLAKE2b-256 |
f59d839588e47ef2ab15743daaf845c92b3c2aec0f187925d3223dd4abeb871c
|
File details
Details for the file e7_switcher-1.0.6-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: e7_switcher-1.0.6-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 560.2 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c47972bf048d94eea0f397b67c3763f69b9ff682882316e2ce9e388ab191c83
|
|
| MD5 |
c0c13ce8b681415b04501048700ce5ac
|
|
| BLAKE2b-256 |
a472b473462dba6ce4cb2ae11d6a64c08dd6389d59d9eb9f84c8120be7bf515b
|
File details
Details for the file e7_switcher-1.0.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: e7_switcher-1.0.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be244e8cf03c8ecc431f5eb02e563f5d421f7fd9cf77eb502f35c5a73d3808df
|
|
| MD5 |
cf69406551c45533e7389d0327d72575
|
|
| BLAKE2b-256 |
ffd16a45accedadd834ed737ed19e1f1e76cde5b77c054ad9a3a101529562f8a
|
File details
Details for the file e7_switcher-1.0.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: e7_switcher-1.0.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93c1f408bd04c727af23e88c56c776211fe4fbab8dc04d48714a9166e6231cf2
|
|
| MD5 |
539d6996e8d02513abd68eabf71678f2
|
|
| BLAKE2b-256 |
210535a5bb912815851e13fa72e4b0f131b16ebcf0914196d249c1a64224276a
|
File details
Details for the file e7_switcher-1.0.6-cp312-cp312-macosx_14_0_arm64.whl.
File metadata
- Download URL: e7_switcher-1.0.6-cp312-cp312-macosx_14_0_arm64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.12, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f301134e0415c89a52d5e105c5b794675c0c2512e682b06d13cb75bf810db62
|
|
| MD5 |
01392055fca0e17c399d7ba7611c9915
|
|
| BLAKE2b-256 |
ba6fd62888e20ab50108dc81d921941983c22178075a8863d89c63ffa7ffb84d
|
File details
Details for the file e7_switcher-1.0.6-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: e7_switcher-1.0.6-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 559.1 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
452c623e15348d24efee46617a23b2abe84012bf61d2d69351048c413e328338
|
|
| MD5 |
6469fa59fdb0cfd272edf1ba66ab814a
|
|
| BLAKE2b-256 |
8bd296c152d78f45daf3581a0244c0565c71652c37b417ccd035ef800aace7a5
|
File details
Details for the file e7_switcher-1.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: e7_switcher-1.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e457f06a6a44435ba5876ef6ee0887e3cba6763b1a8159fd32e830ac59055865
|
|
| MD5 |
3bce7d95576bd402733ecf90dedd9936
|
|
| BLAKE2b-256 |
afc2e3762d48faf47900bde9556df76fd913eb2d79e48f4dbcf460f6466b1687
|
File details
Details for the file e7_switcher-1.0.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: e7_switcher-1.0.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6af2e3d9b15796a89bf27d0f52e4bc0954b2989773e96e521085af6a9811938
|
|
| MD5 |
7d921cb6fc3a23fd25c3d8155f13d1dd
|
|
| BLAKE2b-256 |
89496a9b8d1f498292e7ce5fb17f66908ac8e7f10f2084e50cb16f1969d4bc49
|
File details
Details for the file e7_switcher-1.0.6-cp311-cp311-macosx_14_0_arm64.whl.
File metadata
- Download URL: e7_switcher-1.0.6-cp311-cp311-macosx_14_0_arm64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.11, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
708a373819c1f6ad7cb3f51f03addd5db46c331f87999cce5720f83c3fbe24f5
|
|
| MD5 |
c5f254620a9499d89ef2ce571395919c
|
|
| BLAKE2b-256 |
b5578a297eca2c4f887871f213a32ee6111adc1d18473c8c83ac14d68a14c310
|