Python bindings for the e7-switcher C++ client
Project description
E7 Switcher Library
A cross-platform library for controlling Switcher smart home devices from ESP32 and desktop platforms (Mac/Linux/Windows), with support for x86_64 and aarch64.
Switcher smart home devices are manufactured by Switcher.
This repo is not affiliated with the Switcher product, it is meant to help give some extra automation capabilities to Switcher devices.
Features
- Control Switcher devices (switches, AC units, etc.)
- Cross-platform compatibility: ESP32, Mac, Linux, and Windows
- CPU architectures: x86_64 and aarch64
- 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 using the PlatformIO registry package name:
lib_deps =
elhanan7/e7-switcher
Note: If you need the latest, unreleased changes, you can depend directly on the Git repository instead. Prefer the registry package for stability.
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
Install from PyPI (recommended):
pip install e7-switcher
Install from source (optional):
# From the repository root
pip install build
python -m build
pip install dist/e7-switcher-1.0.6-py3-none-any.whl
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 (optional auto-off timer in minutes)
client.control_switch("Your Switch Name", "on", 0); // action: "on"/"off", operation_time minutes
// 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 (optional auto-off timer in minutes)
client.control_switch("Your Switch Name", True, 0) # Turn on, no timer
client.control_switch("Your Switch Name", False, 10) # Turn off with 10-minute timer
# 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'}")
Fluent AC Control (Python)
You can use a fluent, chainable interface to control AC devices. The fluent builder initializes from the current AC status and lets you set properties in a readable manner before executing with do().
from e7_switcher import E7SwitcherClient
client = E7SwitcherClient("your_account", "your_password")
# Start from current state, set target state fluently, then execute
client.control_ac_fluent("Your AC Name").cool().fan_low().temperature(22).on().do()
# Flexible setters: strings, enums, ints, and booleans
client.control_ac_fluent("Bedroom").mode("heat").fan("HIGH").swing_off().timer(30).on().do()
# Using enums explicitly
from e7_switcher import ACMode, ACFanSpeed, ACSwing
client.control_ac_fluent("Office").mode(ACMode.DRY).fan(ACFanSpeed.FAN_AUTO).swing(ACSwing.SWING_ON).do()
Available chainable methods include:
- Power:
on(),off(),power(value) - Mode:
mode(value),auto(),dry(),fan_mode(),cool(),heat() - Temperature:
temperature(value) - Fan speed:
fan(value),fan_low(),fan_medium(),fan_high(),fan_auto() - Swing:
swing(value),swing_on(),swing_off() - Timer:
operation_time(minutes),timer(minutes) - Execute:
do()
Notes:
- The fluent API accepts Python enums (from
e7_switcher.enums), strings (e.g.,"cool","FAN_HIGH"), integers, and booleans where applicable. - The Python enums are converted internally to the native
_coreenums for the underlying call, so you can use the Pythonic API without worrying about low-level details.
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:
python python/examples/example_usage.py --account your_account --password your_password list
python python/examples/example_usage.py --account your_account --password your_password switch-status --device "Your Switch Name"
python 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.7.tar.gz.
File metadata
- Download URL: e7_switcher-1.0.7.tar.gz
- Upload date:
- Size: 48.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90811b7c404a1969af83412b3d2d35f1b54e3756d3d38b039a2b8c8769e20b59
|
|
| MD5 |
21faca29f4caeda0d7d50e330fbd85e9
|
|
| BLAKE2b-256 |
543666a672c06a763099298b1a79bca86ddc8f115c56d87d76ffb2740103937e
|
File details
Details for the file e7_switcher-1.0.7-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: e7_switcher-1.0.7-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 1.8 MB
- 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 |
2add8f6e3130e6df7e40d74aae4b378c06739755bfaab8171830bf476b5414f8
|
|
| MD5 |
6fcb7389e832ac213ad56bc96b61c016
|
|
| BLAKE2b-256 |
922ba3fbdd3222d55e82d9189a07625941f09ce6dd4441ed30e575592ff07956
|
File details
Details for the file e7_switcher-1.0.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: e7_switcher-1.0.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.4 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 |
491f81b4e02a9e3570fabe0bd3b97dac2263e8f1656dfc7966dcf1e46599f394
|
|
| MD5 |
ba28e0de156a82d2ccf5e8613185ded0
|
|
| BLAKE2b-256 |
e49d0dee3400c3ff16b5ff310a655318eb8305a1c6ed33fa2f4d991980b58892
|
File details
Details for the file e7_switcher-1.0.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: e7_switcher-1.0.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.1 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 |
62b8288e80826f898c4a33e2946ce769a9796174095c0b376bcc13939c03ba21
|
|
| MD5 |
a060ff8eb21d9ec2cd75be4328373f24
|
|
| BLAKE2b-256 |
59513b6aa387340c326a52f1a2f011fda4378d930dee492f91cc28abafd2fcff
|
File details
Details for the file e7_switcher-1.0.7-cp313-cp313-macosx_14_0_arm64.whl.
File metadata
- Download URL: e7_switcher-1.0.7-cp313-cp313-macosx_14_0_arm64.whl
- Upload date:
- Size: 2.8 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 |
f6d9f7aad79237c9955d8a1682a90960b6b37aeb5a4dedf80a40087a6c0f4205
|
|
| MD5 |
5d341d37d6416af9e29ff7ac920f3535
|
|
| BLAKE2b-256 |
e69427ee31d7e21d5ce29d8565b4222b0ab914817c8d436e1fc8f18988b14e1e
|
File details
Details for the file e7_switcher-1.0.7-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: e7_switcher-1.0.7-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 1.7 MB
- 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 |
b3bfe9795db796ef107b8b76d4c627eaf08381a7b1beb83291aafcf21076b18d
|
|
| MD5 |
3ba75b135852eef202bc8f7edc792a55
|
|
| BLAKE2b-256 |
5eb27c9e90e9860974a32e5dd733d083a0b1960213f1cc8ca35fad163ff43b1b
|
File details
Details for the file e7_switcher-1.0.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: e7_switcher-1.0.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.4 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 |
1fb3450bb2ff337eb2c5020203d8200706cd777a5e9b5e913080bf89030ab097
|
|
| MD5 |
1e71c602a7b3741c4d2d3bcaabebb4b3
|
|
| BLAKE2b-256 |
2a4621b01f54c7e1d83fbe65f5240b8e55d421c7d14327cb5ba450d2c900a438
|
File details
Details for the file e7_switcher-1.0.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: e7_switcher-1.0.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.1 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 |
49257d10d2f03b7659e840813f6fcfe66b75936eef126e99c15f720295dd0900
|
|
| MD5 |
2b8cb96a845a47b62e9da7ec5726e743
|
|
| BLAKE2b-256 |
c50611d9b40b6e70363906c6264106b0224a3b98a76b40728108c54cace19faa
|
File details
Details for the file e7_switcher-1.0.7-cp312-cp312-macosx_14_0_arm64.whl.
File metadata
- Download URL: e7_switcher-1.0.7-cp312-cp312-macosx_14_0_arm64.whl
- Upload date:
- Size: 2.8 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 |
3edae1d40e6f044237bcbaee0a44a75d8993161cbcda4231b6cecef7ace7cc3c
|
|
| MD5 |
24864c6a607c97ee0715fd44efb5001a
|
|
| BLAKE2b-256 |
e16752c873836c904a3a86edd0fae474ca0fccac7911b7d07feeb2aaa3db88a2
|
File details
Details for the file e7_switcher-1.0.7-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: e7_switcher-1.0.7-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 1.7 MB
- 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 |
6a909f32600a852dd61fa8c88800b9f64801f3e08790bac7c16d3b17d45be8a0
|
|
| MD5 |
f87b3c4f219d1ee51e176282109c47a0
|
|
| BLAKE2b-256 |
dd562cb9693d69cc163a1a9589b6ca515920bbbaad22c2597fafc41499a28d28
|
File details
Details for the file e7_switcher-1.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: e7_switcher-1.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.4 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 |
43fc1c1115d4be2ac770dd97adfac49cf6d69926a9039ae51d693a3ee4774925
|
|
| MD5 |
07f2016823a088e3fb386b4d5accdbab
|
|
| BLAKE2b-256 |
a62eac3f3ff0c87f08d69ed39e77310b8f9c0f86e3cf74331eafe2f463dccabf
|
File details
Details for the file e7_switcher-1.0.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: e7_switcher-1.0.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.1 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 |
53a05f8dde5ab8b16957560f49436c5d8d2e7f044b049fc213bcd7a08745fda0
|
|
| MD5 |
556e41587e5eb3644dc3912804290d4c
|
|
| BLAKE2b-256 |
2b2d5027253f8f6a85a621997f4bcd4b4f7225051c832a24dd39edd34f14c820
|
File details
Details for the file e7_switcher-1.0.7-cp311-cp311-macosx_14_0_arm64.whl.
File metadata
- Download URL: e7_switcher-1.0.7-cp311-cp311-macosx_14_0_arm64.whl
- Upload date:
- Size: 2.8 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 |
af15cc113533bfdd736e06de3c83dff63aaa5bc259722a9854506b1c67c8a802
|
|
| MD5 |
57f02a0c1dd4a0c95c12b8fa961a4f19
|
|
| BLAKE2b-256 |
9495a8c7d77957dd8727a93044042b2cb22884327620ca113495f5866648bdd4
|