A Python module for operating network connected power strips
Project description
MaxSmart Python Module
Version: 2.0.0-beta1
The maxsmart
module is designed to operate Revogi-based Max Hauri MaxSmart PowerStrips running on v1.x firmware. It enables local communication with the power strips without requiring any cloud connection or account.
Note: If you have upgraded your MaxSmart app to version 2, it may have pushed a new firmware to your devices, rendering this module incompatible.
Introduction
The maxsmart
module is developed to control Max Hauri MaxSmart devices, specifically, the MaxSmart Power Station and the MaxSmart Power Plug. These are smart home devices that provide remote control and automation capabilities. Please note that these products are no longer available on the Swiss market under the Max Hauri brand and are considered end-of-life.
MaxSmart Overview
The MaxSmart Power Station and Power Plug are part of the MaxSmart product line, designed for smart home applications. These devices communicate over a local network using HTTP requests.
The maxsmart
module consists of two main classes:
1. MaxSmartDevice
This class is used to interact with a specific MaxSmart device. It allows you to perform various operations like turning ports on and off, checking their states, and retrieving power consumption data.
Key Methods:
turn_on(port)
: Turns on the specified port or all ports ifport
is set to 0.turn_off(port)
: Turns off the specified port or all ports ifport
is set to 0.check_state()
: Returns the current state of all ports.check_port_state(port)
: Returns the state of a specified port.get_power_data(port)
: Retrieves real-time power consumption data for a specific port.get_hourly_data(port)
: Retrieves 24-hour consumption data for a specific port.retrieve_port_names()
: Retrieves and returns the names of the ports on the device.
2. MaxSmartDiscovery
This class is used to discover MaxSmart devices on the local network.
Key Method:
discover_maxsmart(ip=None)
: Discovers MaxSmart devices. Ifip
is not provided, it sends a broadcast to the local network. If an IP address is provided, it sends a unicast message to that specific device.
Communication
The communication with MaxSmart devices is done through HTTP GET requests over a local network. It's important to note that this communication is unsecured and in clear text. Therefore, it is advised to use the module in a trusted network environment.
Prerequisites
Before using the maxsmart
module, make sure you have the following prerequisites:
- Python 3.x installed on your system.
Installation
Install from Source (Local)
Since the maxsmart
module is not yet published on PyPI, you can install it locally from the source code. Follow these steps:
-
Clone the Repository:
git clone https://github.com/your_username/maxsmart.git cd maxsmart
-
Install with pip: You can install the module along with its dependencies using:
pip install .
This will install the maxsmart
module and its dependencies from the local source.
Usage
Discovering Devices
To discover MaxSmart devices, use the MaxSmartDiscovery
class as follows:
from maxsmart import MaxSmartDiscovery
# Discover all MaxSmart devices on the network
devices = MaxSmartDiscovery.discover_maxsmart()
print(devices) # Outputs a list of discovered devices
Controlling a Device
Once you have the IP address of your MaxSmart device, you can create an instance of the MaxSmartDevice
class and control the device:
from maxsmart import MaxSmartDevice
# Create an instance of the MaxSmartDevice with the device's IP address
device = MaxSmartDevice('192.168.0.25')
# Turn on port 1
device.turn_on(1)
# Check state of all ports
state = device.check_state()
print(state)
Full Example
Here's a quick example demonstrating the discovery and control of MaxSmart devices:
from maxsmart import MaxSmartDiscovery, MaxSmartDevice
# Discover devices
devices = MaxSmartDiscovery.discover_maxsmart()
if devices:
selected_device = devices[0] # Select the first discovered device
device = MaxSmartDevice(selected_device['ip'])
# Retrieve port names
port_names = device.retrieve_port_names()
print("Port Names:", port_names)
# Turn on port 1 and display current state
device.turn_on(1)
print("Current State:", device.check_state())
else:
print("No MaxSmart devices found.")
Example Scripts
The Example Scripts directory provided allows you to perform a series of tests on a MaxSmart power strip. They are also meant as a guideline for you to create your own scripts or integration.
They cover various functionalities such as powering on and off individual ports, retrieving real-time consumption data, and obtaining 24-hour consumption data, etc...
Running the example Scripts
Refer to the example Scripts Readme for instructions on how to run the scripts.
Credits
The maxsmart
module has been made possible by the reverse engineering and documentation work done by GitHub user @altery
. They have provided valuable insights into the communication protocol of MaxSmart PowerStrips. You can find their documentation here: GitHub - mh-maxsmart-powerstation
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file maxsmart-2.0.0b1.tar.gz
.
File metadata
- Download URL: maxsmart-2.0.0b1.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3cb499d742b32b7b8752d69db8164277e9910186f069bca1dc862ac111d72bd |
|
MD5 | f9e831ddd97d3e2cfaaf06b8ba1a1da0 |
|
BLAKE2b-256 | cbc8acb4fd1df57d4a42460f3ecefb1a9070b9ea0f161671af7c26a3f36ed9a3 |
File details
Details for the file maxsmart-2.0.0b1-py3-none-any.whl
.
File metadata
- Download URL: maxsmart-2.0.0b1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52bec20b65e4476d54c05df6a5db4857f3ec45a6a6ec22f03e181d6a3bb83abf |
|
MD5 | 2ac3186af60b26a359a5ecdd166fce00 |
|
BLAKE2b-256 | 9ad197028caf0c608c6fc53161fed811d6332882c31140fb4bcd4f1d49353b65 |