Skip to main content

Python client for CoolAutomation HVAC gateways.

Project description

pycoolmasternet-ng

A Python 3.9+ library for interacting with a CoolMasterNet HVAC bridge. This is a fork of pycoolmasternet-async with significant changes:

Pluggable transports

Transports - methods that define communication with the CoolMasterNet device - are now in classes. TCP/IP and RS232 is implemented, REST is TODO, and maybe at some point CoolAutomation's cloud-based service can be reverse-engineered and implemented too (not sure if their cloud service just forwards commands or if it operates at a higher level).

More "Pythonic"

Most values and data objects are mapped to Python classes - exceptions, enums, etc.

Autodiscovery of device capabilities

Device capabilities are now inferred from "properties" saved in the CoolMasterNet unit. This means the CM device holds all configuration and the home automation controllers can just autodiscover them. See the CoolMasterNet manual on how to set these (you'll need to manually Telnet/serial in to set them first).

Device capability database

There's a (work-in-progress, currently Mitsubishi Electric only) database of device capabilities such as allowed temperature ranges, etc - this would allow consumers of this library (such as home automation integrations) to autodiscover those and customize their UI accordingly.

TODO

  • synchronous (blocking) interface
  • improve the device DB for non-Mitsubishi-Electric units
  • REST transport
  • support advanced CoolMasterNet functionality (I only have the CoolLinkHub with CoolPlugs so can't test that yet)

Installation

You can install pycoolmasternet-async from PyPI:

pip3 install pycoolmasternet-ng

Python 3.9 and above are supported. As this is primarily designed for use in Home Assistant, support for prior Python versions isn't a priority.

Extra protocols such as serial require additional dependencies:

pip3 install pycoolmasternet-ng[serial]

Basic usage

from pycoolmasternet_ng import transports, models, structures, constants

# first create a transport - TCP/IP (CoolMasterNet calls this "aserver")
ts = transports.TCPTransport("192.168.0.123", port=12345)

# or Serial
ts = transports.SerialTransport('/dev/ttyS0', 9600)

# now create a gateway connected to your transport
# this will internally populate a cache of models.Device objects with their current state

gw = await models.Gateway.from_transport(transport=ts)

# a dictionary of structures.UID: models.Device
devices = gw.devices

# get device with UID L5.001
device = devices[structures.UID.from_string('L5.001')]

# get device info

device.power_state  # True
device.mode  # constants.Mode.COOL
device.fan_mode  # constants.FanMode.LOW
device.louver_position  # constants.LouverPositionState.NOT_SUPPORTED
device.target_temperature  # Decimal('21')
device.current_temperature  # Decimal('22')
device.temperature_unit  # 'C'
device.error_code  # None
device.demand  # True


# refresh that device - this will talk to the gateway to query the device's status and update the object
await device.refresh()

# now check the updated values

device.current_temperature  # Decimal('21')
device.demand  # False


# turn device off
await device.set_power_state(False)

# see the updated status
device.power_state  # False


# make multiple changes
await device.set_mode(constants.Mode.HEAT, refresh=False)
await device.set_temperature(23, refresh=False)
await device.set_power_state(refresh=False)

# note that device.power_state is still False as we haven't refreshed
device.power_state  # False

# now refresh explicitly
await device.refresh()

# now device.power_state is up to date
device.power_state  # True

# refresh all devices on the gateway
await gw.refresh()

# now gw.devices has been rebuilt with updated models.Device objects
# note that the objects are replaced and not updated in-place

devices[structures.UID.from_string('L5.001')] is device  ## False

Credits

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

pycoolmasternet-ng-0.3.2.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycoolmasternet_ng-0.3.2-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file pycoolmasternet-ng-0.3.2.tar.gz.

File metadata

  • Download URL: pycoolmasternet-ng-0.3.2.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for pycoolmasternet-ng-0.3.2.tar.gz
Algorithm Hash digest
SHA256 6966a8f15c04611c1b18186365fb21eb3ea3d48e878a6f9b370572e125b0ac21
MD5 28a20f5062df49c322e4e3dafc9c6843
BLAKE2b-256 16c8e5768fa37051f2d77aea2cb22ae1b38e23e73d345ba2e221a7c2139cafed

See more details on using hashes here.

File details

Details for the file pycoolmasternet_ng-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pycoolmasternet_ng-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3b5852cc1caf566255456eb7bf9733921b3141d20b07588abc0a28df56c00e1b
MD5 700c84f3034945c61cf56d579ff5cbfa
BLAKE2b-256 b33c5d6ee47537eb0fbb459e12fed53831c2a48f51a84908ab95a9a1a7d9df47

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page