github thomluther/anker-solix-api v3.5.0
3.5.0

latest releases: v3.7.0, v3.6.3, v3.6.2...
7 months ago

Enhancements:

  • Added type definitions for new device models
  • Added command descriptions for various devices as provided by device owners
  • Support description of enforced signing for value decoding
  • Harmonized MQTT mapping keywords for command and message descriptions
  • Centralized validation of MQTT controls for mandatory and optional command parameter values
  • Centralized MQTT command composition, based on supported and described MQTT command messages per device model
  • Each SolixMqttDevice inherited class instance can use the common methods
  • A SolixMqttDevice instance can be created with the SolixMqttDeviceFactory.create_device() method. The factory must be initialized with the existing Api session instance and the device serial number, which must exist in the api.devices cache.
from api.mqtt_factory import SolixMqttDeviceFactory
from api.mqttcmdmap import SolixMqttCommands # Dataclass with all defined commands

# Create MQTT device instance
mdev = SolixMqttDeviceFactory(myapi, device_sn).create_device()

# get list of supported controls (commands) for the device
controls = list(mdev.controls.keys())

# get full description of control if required and supported by the device
ctrl_desc = mdev.controls.get(SolixMqttCommands.device_timeout_minutes)

# get parameters / value description mapping for control based on various parameter characteristics
mdev.get_cmd_parms(cmd: str, defaults: bool = False, state_parms: bool = False, follow_parms: bool = False, all: bool = False) -> dict:
      """Get dictionary with parameters and value descriptions for provided command."""

# get the provided or first mandatory parameter value options for the control
mdev.get_cmd_parm_option_map(cmd: str, parm: str | None = None) -> dict:
      """Get dictionary with options mapping for first mandatory or the provided parameter."""

# get the validated data field value for a control and optional parameter. Only required if separate validation must be done before executing the command
mdev.validate_cmd_value(cmd: str, value: Any, parm: str | None = None) -> int | float | str | bool | None:
      """Get validated command value for device control or None if anything invalid."""

# execute a command, which will also validate all required command parameters using validate_cmd_value
# Parameter and value can be specified individually or via a parm_map for multiple required/optional parameters. They will be merged prior evaluation
await mdev.run_command(cmd: str, value: Any = None, parm: str | None = None, parm_map: dict | None = None, toFile: bool = False,) -> dict | None:
      """Validate and send a supported device command that requires a single parameter value at most."""

Fixes:

  • Fixed potential hang condition during cleanup of MQTT connection
  • Fixed decoding of temperature values to support negative values
  • Fixed decoding of large duration values that should not be decoded as signed integers
  • Fixed code to determine installed expansion batteries
  • Avoid extraction of extraneous expansion data if expansions are not installed
  • Various other fixes in the codebase

Important

Solarbank Multisystems still have significant consumption data reporting issues to the cloud if they are not used with the owner account and triggered for real time data updates, see Add support for multi-system Solarbanks.

Breaking changes:

  • Continuous renaming of MQTT data fields may be required as values are understood, validated and merged across the various devices
  • The device agnostic MQTT device modules and example code has been removed (C1000 and F3800)
    • A common, scalable and modular command framework was implemented that is based on command descriptions in the MQTT mapping of each device model.
  • MQTT device classes per device family/category have been introduced
    • This will be enhanced in future if new device categories will be described

Full Changelog: v3.4.2...v3.5.0

Don't miss a new anker-solix-api release

NewReleases is sending notifications on new releases.