Package: maxsmart
MaxSmart Python ModuleThemaxsmartmodule 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.IntroductionThemaxsmartmodule 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 OverviewThe MaxSmart Power Station and Power Plug are part of the MaxSmart product line, designed for smart home applications. These devices are based on the Revogi Smart Power Strip.It's important to note that MaxSmart devices were designed to be controlled remotely over the internet using a Max Hauri cloud account. However, with the products reaching their end-of-life and the discontinuation of support for version 1.x of the cloud, there have been issues reported by users, including potential interruptions and disappearing cloud accounts. Upgrading to firmware version 2.x changes the API and removes the possibility of local control.While themaxsmartmodule has been specifically developed for Revogi-based Max Hauri MaxSmart PowerStrips, there have been some reports of potential compatibility with other brands and models. These include:Max Hauri MaxSmart (v1.x)Revogi Smart Power StripExtel SokyMCL DOM-PPS06IHowever, compatibility with these brands and models may vary, and it's recommended to perform thorough testing to ensure proper functionality.Please keep in mind that themaxsmartmodule is primarily designed for Revogi-based Max Hauri MaxSmart PowerStrips running on v1.x firmware, and compatibility with other devices or firmware versions is not guaranteed.Thetest scriptmay allow you to test this easily.Disclaimer: I'm not responsible for any damage or loss of configuration of your device. Make this at your own risk.MaxSmart ControlMaxSmart devices can be controlled via the MaxSmart app, available on both Android and iOS, or through the MaxSmart website. However, due to potential issues with the Max Hauri cloud and the discontinuation of support for version 1.x devices, it is recommended to avoid using the cloud account and associated applications with version 1.x devices.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.Test ScriptThe test script provided allows you to perform a series of tests on a MaxSmart power strip. It covers various functionalities such as powering on and off individual ports, retrieving real-time consumption data, and obtaining 24-hour consumption data.PrerequisitesBefore running the test script, make sure you have the following prerequisites:Python 3.x installed on your system.ThemaxsmartPython module installed. You can install it by following the instructions in theInstallationsection.Running the Test ScriptTo run the test script, execute the following command in your terminal:pythontest_scripts/test_script.pyThe script will attempt to discover MaxSmart devices on the network. If no devices are found, it will display an error message. If devices are found, you will be presented with a menu to select a device for testing.Follow the on-screen instructions and warnings to proceed with the test.InstallationTo install themaxsmartmodule, you can usepip, the Python package installer. Open your terminal or command prompt and run the following command:pipinstallmaxsmartThis will install themaxsmartmodule and its dependencies.UsageDiscoveryDiscovery will help you find your MaxSmart device details on the local network. You can use theMaxSmartDiscoveryclass. There are two ways of using this class:Without argument, MaxSmartDiscovery will send a broadcast to the local network and expect all available devices to send data in return.frommaxsmartimportMaxSmartDiscoverydevices=MaxSmartDiscovery.discover_maxsmart()Note:If broadcast is blocked on your network, you will not get any result.With an ip address as argument, MaxSmartDiscovery will send a unicast message to the specified IP address. In that case, only that specific device, if present, will return data. You'll have therefore to run discovery for each specific MaxSmart device.frommaxsmartimportMaxSmartDiscoverydevices=MaxSmartDiscovery.discover_maxsmart(192.168.0.25)Thediscover_maxsmartmethod returns a list of dictionaries, each representing a discovered MaxSmart device on the network. Each dictionary contains information such as the device's IP address (ip), serial number (sn), name, port name dictonary (pname), firmware version (ver).Device OperationsWhen you have the ip addresses of your devices, you can operate using the MaxSmartDevice method:The MaxSmart Power strip as 6 ports, and the Smart plug has 1 port. Operations are made against port numbers.Import the module and create an instance of theMaxSmartDeviceclass, providing the IP address of the device. For example:frommaxsmartimportMaxSmartDevicedevice=MaxSmartDevice(192.168.0.25)Use the available methods to control the device. Note that port 0 is a master port affecting all ports on the device simultaneously:Turn on a specific port/socket:device.turn_on(1)# Turns on port 1Turn on all ports/sockets:device.turn_on(0)# Turns on all portsTurn off a specific port/socket:device.turn_off(2)# Turns off port 2Check the state of all ports/sockets:state=device.check_state()# Returns a list with the state of each portCheck the state of a specific port/socket:port_state=device.check_port_state(3)# Returns the state of port 3Retrieve real-time power consumption data for a specific port/socket (watts):power_data=device.get_power_data(3)# Get the power data for the specified portRetrieve 24-hour points of consumption data for a specific port/socket (kWh):hourly_data=device.get_hourly_data(3)# Get the last 24 points of hourly consumption data for the specified portDISCLAIMER:Please note that theMaxSmartDeviceclass is specifically designed for Revogi-based Max Hauri MaxSmart PowerStrips running on v1.30 firmware. Compatibility with other devices or firmware versions is not guaranteed.CreditsThemaxsmartmodule 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-powerstationLicenseMIT