Skip to main content

Local control for choochoo based thermostats

Project description

steamloop

CI Status Documentation Status Test coverage percentage

uv Ruff pre-commit

PyPI Version Supported Python versions License


Async Python library for local control of thermostat devices over mTLS (port 7878).

Installation

pip install steamloop

CLI

Pairing

Put the thermostat in pairing mode (Menu > Settings > Remote Access > Pair New Device), then:

steamloop 192.168.1.100 --pair

This saves a pairing file in the current directory with the secret key.

Monitoring

steamloop 192.168.1.100

Interactive commands: status, heat <temp>, cool <temp>, mode <off|auto|cool|heat>, fan <auto|on|circulate>, eheat <on|off>, help.

Library Usage

import asyncio
from steamloop import ThermostatConnection, ZoneMode, FanMode

async def main():
    conn = ThermostatConnection(
        "192.168.1.100",
        secret_key="your-secret-key-from-pairing",
    )
    async with conn:
        # State is populated automatically from thermostat events
        for zone_id, zone in conn.state.zones.items():
            print(f"{zone.name}: {zone.indoor_temperature}°F")

        # Send commands (sync — no await needed)
        conn.set_temperature_setpoint("1", heat_setpoint="72")
        conn.set_zone_mode("1", ZoneMode.COOL)
        conn.set_fan_mode(FanMode.AUTO)

asyncio.run(main())

Pairing Programmatically

pair() returns the secret key directly — store it however you like:

from steamloop import ThermostatConnection

async def pair(ip: str) -> str:
    conn = ThermostatConnection(ip, secret_key="")
    try:
        await conn.connect()
        ssk = await conn.pair()
        return ssk["secret_key"]  # store in a database, config entry, etc.
    finally:
        await conn.disconnect()

Or use the built-in file helpers to save/load pairing data to disk:

from steamloop import ThermostatConnection, save_pairing, load_pairing

# Save after pairing
await save_pairing(ip, {
    "secret_key": secret_key,
    "device_type": "automation",
    "device_id": "module",
})

# Load later
pairing = await load_pairing(ip)
conn = ThermostatConnection(ip, secret_key=pairing["secret_key"])

Event Callbacks

def on_event(msg):
    print("Received:", msg)

remove = conn.add_event_callback(on_event)
# later: remove() to unregister

Home Assistant Integration

Key design points for using steamloop in a Home Assistant integration:

  • Commands are syncset_zone_mode(), set_fan_mode(), set_temperature_setpoint() use transport.write() internally, so they won't block the event loop. No await needed.
  • State is always fresh — the asyncio.Protocol receives events via data_received() and updates conn.state automatically. Just read properties directly.
  • Auto-reconnect — after calling start_background_tasks(), the connection automatically reconnects with exponential backoff (5s, 10s, 20s, ... up to 5 min).
  • Event callbacks — use add_event_callback() to trigger async_write_ha_state() when the thermostat pushes updates.
  • Multi-zone — create one ClimateEntity per conn.state.zones entry. Zones are populated automatically after login.

API Reference

ThermostatConnection(ip, port=7878, *, secret_key, cert_set=None, device_type="automation", device_id="module")

Method Async Description
connect() yes Establish mTLS connection
login() yes Authenticate with secret key
pair() yes Pair and receive secret key
start_background_tasks() no Start heartbeat + auto-reconnect
disconnect() yes Close connection and stop tasks
set_temperature_setpoint(zone_id, *, heat_setpoint, cool_setpoint, hold_type) no Set zone temperature
set_zone_mode(zone_id, mode) no Set zone HVAC mode
set_fan_mode(mode) no Set fan mode
set_emergency_heat(enabled) no Toggle emergency heat
add_event_callback(fn) no Register event listener (returns unregister callable)

Supports async with for automatic connect/login/disconnect:

async with ThermostatConnection(ip, secret_key=key) as conn:
    ...  # connected, logged in, background tasks running
# automatically disconnected

Enums

  • ZoneModeOFF, AUTO, COOL, HEAT
  • FanModeAUTO, ALWAYS_ON, CIRCULATE
  • HoldTypeUNDEFINED, MANUAL, SCHEDULE, HOLD

State

  • conn.state.zonesdict[str, Zone] with temperature, setpoints, mode per zone
  • conn.state.fan_mode — current FanMode
  • conn.state.supported_modeslist[ZoneMode]
  • conn.state.emergency_heat / relative_humidity / cooling_active / heating_active

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

Credits

Copier

This package was created with Copier and the browniebroke/pypackage-template project template.

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

steamloop-1.1.0.tar.gz (41.6 kB view details)

Uploaded Source

Built Distribution

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

steamloop-1.1.0-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

Details for the file steamloop-1.1.0.tar.gz.

File metadata

  • Download URL: steamloop-1.1.0.tar.gz
  • Upload date:
  • Size: 41.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for steamloop-1.1.0.tar.gz
Algorithm Hash digest
SHA256 eecd2fc71d1ca7289e5464d5599d968b2590466081ce35312301e483831dbd80
MD5 95dcbe6ee02912729302351ba3443f2d
BLAKE2b-256 c9b1dc6af2bfb9caf57f0f33ac62f87ae2f6d68ca027c6ebb2d571f5ad5ad13b

See more details on using hashes here.

Provenance

The following attestation bundles were made for steamloop-1.1.0.tar.gz:

Publisher: ci.yml on hvaclibs/steamloop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file steamloop-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: steamloop-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 28.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for steamloop-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e261de2384354cbc0492528c79ba08d4adf0ed0705f8f96479ef985f2479fc5d
MD5 58fbc1e94eeff58d919c4f5163fe7400
BLAKE2b-256 23091a7310606987bb58e7c66b73bca4aaaa1c6979c0ef39e799463972b79dd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for steamloop-1.1.0-py3-none-any.whl:

Publisher: ci.yml on hvaclibs/steamloop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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