Skip to main content

🌡️ Open Polaris Local API

Asynchronous Python library for Tecnosystemi Polaris 5X HVAC Control Unit devices

Python Version License Version PyPI Tests

Features • Installation • Quick Start • Documentation • Examples • Scripts • Testing


✨ Features

🚀 Performance

  • Built with asyncio for non-blocking operations
  • Efficient TCP communication — short-lived connections per command (mirrors official app)
  • Automatic retry on timeout or transient failure
  • Compact stato_r polling with transparent fallback to full stato

🔄 Reliability

  • Auto-retry with configurable attempts and delay
  • Graceful fallback: stato_r → stato on older firmware
  • Robust error decoding via bitmask for both CU and zone errors

🎯 Developer Friendly

  • Type-safe dataclasses — PolarisDevice and PolarisZone
  • Async context manager support
  • Comprehensive logging with optional verbose mode
  • Models parse local TCP replies and cloud-shaped (PascalCase) payloads; the client itself talks only local TCP (no cloud client)

🔍 Auto-Discovery

  • Subnet scan — finds all Polaris devices on your LAN without knowing their IPs
  • Concurrent TCP probing with configurable timeout and concurrency
  • Identifies devices by validating the Polaris protocol response

🎛️ Full Control

  • CU-level: power, cooling mode, operating mode
  • Zone-level: temperature setpoint, on/off, chrono mode, fan speed, shutter
  • Human-readable error decoding (bitmask → error string list)

📦 Installation

pip install open-polaris-local-api

Home Assistant integration

Add to your integration's manifest.json:

"requirements": [
  "open-polaris-local-api==1.2.4"
]

Manual

  1. Clone this repository into your project
  2. Ensure the open_polaris_local_api/ folder is on your Python path
  3. Import with from open_polaris_local_api import PolarisLocalClient

🚀 Quick Start

Auto-Discovery

Find all Polaris devices on your network without knowing their IPs:

import asyncio
from open_polaris_local_api import PolarisAutoDiscovery

async def main():
    ips = await PolarisAutoDiscovery.discover(pin="1234", subnet="192.168.1.0/24")
    print(f"Found {len(ips)} device(s): {ips}")
    # ["192.168.1.42"]

asyncio.run(main())

Single Device

import asyncio
from open_polaris_local_api import PolarisLocalClient

async def main():
    client = PolarisLocalClient(
        ip="192.168.1.100",
        pin="1234",
        device_id="living_room",
        verbose=True,
    )

    async with client:
        device, zones = await client.async_update()
        print(f"✓ {device.name} — {device.cooling_mode_name}, on={device.is_on}")

        for zone in zones:
            print(f"  Zone {zone.zone_id} '{zone.name}': {zone.current_temp}°C → {zone.set_temp}°C")

        # Turn on and set heating
        await client.set_heating_mode()
        await client.set_zone_temp(zones[0], 21.0)

if __name__ == "__main__":
    asyncio.run(main())

Zone Control

async def control_zones():
    async with PolarisLocalClient(ip="192.168.1.100", pin="1234") as client:
        _, zones = await client.async_update()

        # Turn off a zone
        await client.turn_zone_off(zones[0])

        # Set temperature on all zones
        for zone in zones:
            await client.set_zone_temp(zone, 20.0)

CU-Level Control

async def control_cu():
    async with PolarisLocalClient(ip="192.168.1.100", pin="1234") as client:
        # Switch to cooling mode (raffrescamento)
        await client.set_cooling_mode(1)

        # Switch to dehumidification
        await client.set_cooling_mode(2)

        # Switch to ventilation
        await client.set_cooling_mode(3)

        # Back to heating
        await client.set_heating_mode()

        # Full power off
        await client.turn_off()

📚 Documentation


🔍 Auto-Discovery

Scans every host in the given subnet over TCP port 1235 and returns the IPs of all responding Polaris devices. No prior knowledge of device IPs required.

from open_polaris_local_api import PolarisAutoDiscovery

ips = await PolarisAutoDiscovery.discover(pin="1234", subnet="192.168.1.0/24")

Parameters

Parameter Type Default Description
pin ⭐ str required 🔐 Device PIN used for the probe
subnet ⭐ str required 🌐 CIDR subnet to scan (e.g. "192.168.1.0/24")
port int 1235 📡 TCP port to probe
probe_timeout float 1.5 ⏱️ Per-host timeout in seconds
max_concurrent int 50 ⚡ Maximum simultaneous TCP probes
verbose bool False 📢 Enable debug logging

Notes

  • A 254-host /24 scan with defaults completes in roughly 8 seconds
  • A reply counts only if it has fw_ver, serial and res 1 or 4. Firmware without stato_r answers res=4; it is discovered only if that reply also carries fw_ver and serial
  • Tune probe_timeout upward if devices are on a slow or congested network

⚙️ Configuration

Constructor Parameters

Parameter Type Default Description
ip ⭐ str required 🌐 IP address of the Polaris CU device
pin ⭐ str required 🔐 PIN code for authentication
device_id str None 🏷️ Friendly identifier (auto-set to polaris_{ip}:{port} if omitted)
port int 1235 📡 TCP port on the device
timeout float 5.0 ⏱️ Per-command socket timeout (seconds)
retry_attempts int 2 🔄 Total attempts per command (including the first)
retry_delay float 1.0 ⏳ Delay between retries (seconds)
verbose bool False 📢 Enable verbose debug logging

🔌 Connection Management

Connect

Verifies connectivity by performing an initial async_update. Sets _connected=True and populates cached device/zones state.

await client.connect()

Raises: TimeoutError on failure. Connection errors (refused, reset) are retried inside the client and also end as TimeoutError.

Disconnect

Marks the client as disconnected. TCP is stateless per-command, so no socket needs closing.

await client.disconnect()
# or
await client.close()
async with PolarisLocalClient(ip="192.168.1.100", pin="1234") as client:
    # automatically connects on enter, disconnects on exit
    device, zones = await client.async_update()

🖥️ Device Control (CU)

Full Status Refresh

device, zones = await client.async_update()

Returns a tuple of (PolarisDevice, list[PolarisZone]) and updates the internal cache.

Raw Status

raw: dict = await client.get_status()

Tries stato_r first (compact), falls back to stato if unsupported (res=4).

Power

await client.turn_on()   # is_off=False
await client.turn_off()  # is_off=True

Operating Mode

await client.set_heating_mode()       # cooling=False, mode=0
await client.set_cooling_mode(1)      # raffrescamento
await client.set_cooling_mode(2)      # dehumidification
await client.set_cooling_mode(3)      # ventilation

Full CU Update

await client.update_cu(
    is_off=False,
    is_cooling=True,
    operating_mode=1,   # 0=heating, 1=cooling, 2=dehum, 3=vent
)

🌡️ Zone Control

Convenience Methods

await client.turn_zone_on(zone)
await client.turn_zone_off(zone)
await client.set_zone_temp(zone, 21.5)

Full Zone Update

await client.update_zone(
    zone,
    is_off=False,
    set_temp=21.0,
    is_crono=False,
    fancoil_set=2,
    serranda_set=3,
)

All parameters are optional; omitted values fall back to the zone's current state.

Note: set_temp must be known (either from last async_update or provided explicitly). If neither is available, ValueError is raised.

Shutter (Serranda)

await client.set_zone_serranda(zone, 3)

Calls update_zone(zone, serranda_set=value) and updates zone.serranda_set. The value goes on the wire as shu_set/fan_set unchanged, except 7 (Auto), which is sent as 16. The command only carries the value when zone.serranda != -1; if the zone also has a fancoil with a set-point, the fancoil value is sent instead.

Values used by the official app: 0 closed, 1–3 A1–A3, 4–6 Auto1–Auto3, 7 Auto.

Zone Details (stato_zona)

stato_r / stato do not include every per-zone field. stato_zona returns fan, fan_set, shu, shu_set, EV, EV_set, v (zone firmware) and m (model).

detail = await client.get_zone_detail(zone.zone_id)   # raw reply dict

details = await client.fetch_all_zone_details()        # {zone_id: detail}
  • get_zone_detail raises TimeoutError when there is no reply, and PolarisApiError when the reply's res is not 1 (a missing res included), as the official app does.
  • fetch_all_zone_details queries every zone in client.zones without errors (num_error == 0), waits 1 s before each request, and copies shu/shu_set/fan/fan_set into each zone's serranda/serranda_set/fancoil/fancoil_set. A zone that fails is logged and left out of the result; its cached values are not changed.
  • async_update() does not call either method.

🗃️ Data Models

PolarisDevice

Represents the Polaris Control Unit (CU).

Property / Field Type Description
serial str Device serial number
name str Device name
fw_ver str Firmware version
ip str IP address
is_off bool Whether CU is off
is_on bool (property) Inverse of is_off
is_cooling bool Cooling active
operating_mode int 0=heating, 1=cooling, 2=dehum, 3=vent
cooling_mode_name str (property) Human-readable mode name
t_can int Canal temperature setpoint (°C)
f_inv int Winter function value (f_inv/fi); the app uses -1 for absent, the library defaults to 0
f_est int Summer function value (f_est/fe); same defaults as f_inv
ir_present int IR module present flag
num_errors int CU error bitmask
has_error bool (property) num_errors != 0
active_errors list[str] (property) Decoded error strings
zones list[PolarisZone] Not filled by async_update (stays []); use the zones it returns or client.zones

PolarisZone

Represents a single HVAC zone.

Property / Field Type Description
zone_id int Zone ID
name str Zone name
current_temp float | None Current temperature (°C)
set_temp float | None Temperature setpoint (°C)
is_off bool Whether zone is off
is_on bool (property) Inverse of is_off
is_cooling bool Cooling active
fancoil int Fan coil current speed (-1 = not installed)
fancoil_set int Fan coil setpoint (-1 = not installed)
serranda int Shutter position (-1 = not installed)
serranda_set int Shutter setpoint (-1 = not installed)
ev int EV field, raw (default 0)
man_crono int man_crono field, raw (default 0)
is_crono_mode bool Chrono (scheduled) mode active
is_master bool Zone is master
humidity float | None Current humidity (%)
set_humidity float | None Humidity setpoint (%)
num_error int Zone error bitmask
has_error bool (property) num_error != 0
active_errors list[str] (property) Decoded error strings
c_badge / c_win Any Badge and window contact fields, raw
raw_data dict Original zone payload

Both models accept both local TCP (snake_case, ridotto, full) and cloud API (PascalCase) response formats via the from_local() factory method.


⚠️ Error Handling

Exceptions

Exception Raised by When
TimeoutError connect, async_update, get_status, get_zone_detail No reply after all retries
PolarisApiError get_zone_detail stato_zona reply with res other than 1
ValueError update_zone, PolarisAutoDiscovery.discover set_temp unknown; invalid or non-IPv4 subnet

Write commands (update_zone, update_cu and the helpers built on them) do not raise when the device does not reply: they log a warning.

from open_polaris_local_api import PolarisApiError

try:
    async with PolarisLocalClient(ip="192.168.1.100", pin="1234") as client:
        device, zones = await client.async_update()
        detail = await client.get_zone_detail(zones[0].zone_id)
except TimeoutError:
    print("Device unreachable")
except PolarisApiError as e:
    print(f"Device returned an error: {e}")

Device / Zone Errors

device, zones = await client.async_update()

if device.has_error:
    print(f"CU errors: {device.active_errors}")

for zone in zones:
    if zone.has_error:
        print(f"Zone '{zone.name}' errors: {zone.active_errors}")

📦 Library Structure

open-polaris-local-api/
├── scripts/
│   ├── bump_version.sh              # Bump version across all files
│   └── run_tests.sh                 # Run the full test suite
├── examples/
│   ├── README.md                    # Examples documentation
│   ├── basic_control.py             # Connect, read status, control a single device
│   ├── auto_discovery.py            # Discover devices then read their status
│   ├── multi_device.py              # Concurrent control of multiple devices
│   └── monitoring.py                # Continuous polling with error alerts
├── docs/app/                        # Official app protocol notes and app-vs-library diff
├── open_polaris_local_api/
│   ├── __init__.py                  # exports: PolarisLocalClient, PolarisApiError, PolarisDevice, PolarisZone, PolarisAutoDiscovery
│   ├── client.py                    # PolarisLocalClient, PolarisApiError
│   ├── models.py                    # PolarisDevice, PolarisZone dataclasses + parsing helpers
│   └── polaris_auto_discovery.py    # PolarisAutoDiscovery — subnet scanner
└── tests/
    ├── test_models.py
    ├── test_polaris_client.py
    └── test_polaris_auto_discovery.py

💡 Examples

Ready-to-run example scripts are available in the examples/ directory. See examples/README.md for full documentation and usage instructions.


🛠️ Scripts

Utility scripts live in the scripts/ directory and must be run from the repo root.

scripts/bump_version.sh

Keeps all version references in sync across pyproject.toml and README.md in one command.

./scripts/bump_version.sh patch     # X.Y.Z → X.Y.(Z+1)
./scripts/bump_version.sh minor     # X.Y.Z → X.(Y+1).0
./scripts/bump_version.sh major     # X.Y.Z → (X+1).0.0
./scripts/bump_version.sh X.Y.Z     # set an explicit version
./scripts/bump_version.sh           # interactive menu

scripts/run_tests.sh

Runs the full unit test suite with verbose output.

./scripts/run_tests.sh

🧪 Testing

./scripts/run_tests.sh

📋 Requirements

  • Python 3.11+
  • asyncio support
  • Local network access to the Polaris CU device (TCP port 1235)
  • No third-party dependencies — stdlib only

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License — see the LICENSE file for details.


🆘 Support

Metadata

Release files for open-polaris-local-api 1.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for open-polaris-local-api 1.2.5
File Size Uploaded Provenance Actions
open_polaris_local_api-1.2.5.tar.gz 29.6 kB With provenance Details for open_polaris_local_api-1.2.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for open-polaris-local-api 1.2.5
File Interpreter ABI Platform Actions
open_polaris_local_api-1.2.5-py3-none-any.whl Python 3 none any Details for open_polaris_local_api-1.2.5-py3-none-any.whl

Total release size: 49.1 kB

Release files / open_polaris_local_api-1.2.5.tar.gz

Download URL open_polaris_local_api-1.2.5.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7af496b9ca7f276444a0da99284678979af489a57638156cc624f4df11df28d9
BLAKE2b-256 checksum
How to use checksums
a0698d1c2f7334d4bdd793d09712f937e1adff661736991f34cf0f8215d05d48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / open_polaris_local_api-1.2.5-py3-none-any.whl

Download URL open_polaris_local_api-1.2.5-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a5148cd324c22e1bae3c6d6334226f9b9bd7089bedf7fbfd66311d57cce5a61
BLAKE2b-256 checksum
How to use checksums
3c8098a94b253a6fc3691f6bd8ca738efe48cc66f1a7880678d3027ee7332a2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for open-polaris-local-api 1.2.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for open_polaris_local_api-1.2.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page