idealclima-modbus 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ check:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.13", "3.14"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v7
18
+
19
+ - name: Install uv
20
+ uses: astral-sh/setup-uv@v10.3.3
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install dependencies
25
+ run: uv sync --frozen --all-extras
26
+
27
+ - name: Run ruff
28
+ run: uv run ruff check .
29
+
30
+ - name: Run mypy
31
+ run: uv run mypy src tests
32
+
33
+ - name: Run pytest
34
+ run: uv run pytest -v --cov=idealclima_modbus --cov-report=term-missing --cov-fail-under=100
@@ -0,0 +1,72 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v7
13
+
14
+ - name: Install uv
15
+ uses: astral-sh/setup-uv@v10.3.3
16
+ with:
17
+ python-version: "3.13"
18
+
19
+ - name: Install dependencies
20
+ run: uv sync --frozen --all-extras
21
+
22
+ - name: Verify release tag matches pyproject.toml version
23
+ env:
24
+ RELEASE_TAG: ${{ github.ref_name }}
25
+ run: |
26
+ uv run --no-sync python - <<'EOF'
27
+ import os
28
+ import tomllib
29
+
30
+ with open("pyproject.toml", "rb") as f:
31
+ version = tomllib.load(f)["project"]["version"]
32
+ raw_tag = os.environ["RELEASE_TAG"]
33
+ tag = raw_tag.removeprefix("v")
34
+ if tag != version:
35
+ raise SystemExit(
36
+ f"Release tag {raw_tag!r} does not match pyproject.toml version {version!r}"
37
+ )
38
+ EOF
39
+
40
+ - name: Run checks
41
+ run: |
42
+ uv run ruff check .
43
+ uv run mypy src tests
44
+ uv run pytest -v --cov=idealclima_modbus --cov-report=term-missing --cov-fail-under=100
45
+
46
+ - name: Build package
47
+ run: uv build
48
+
49
+ - name: Upload build artifacts
50
+ uses: actions/upload-artifact@v7
51
+ with:
52
+ name: dist
53
+ path: dist/
54
+
55
+ publish:
56
+ needs: build
57
+ runs-on: ubuntu-latest
58
+ environment:
59
+ name: pypi
60
+ url: https://pypi.org/p/idealclima-modbus
61
+ permissions:
62
+ id-token: write
63
+
64
+ steps:
65
+ - name: Download build artifacts
66
+ uses: actions/download-artifact@v8
67
+ with:
68
+ name: dist
69
+ path: dist/
70
+
71
+ - name: Publish to PyPI
72
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,26 @@
1
+ # Virtual environments
2
+ .venv/
3
+ venv/
4
+
5
+ # Python caches and build artifacts
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+ *.egg-info/
10
+ dist/
11
+ build/
12
+ .eggs/
13
+
14
+ # Tool caches
15
+ .mypy_cache/
16
+ .pytest_cache/
17
+ .ruff_cache/
18
+
19
+ # Coverage
20
+ .coverage
21
+ htmlcov/
22
+
23
+ # OS / IDE
24
+ .DS_Store
25
+ .vscode/
26
+ .idea/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Claudio Ruggeri - CR-Tech
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,71 @@
1
+ Metadata-Version: 2.5
2
+ Name: idealclima-modbus
3
+ Version: 0.2.0
4
+ Summary: Async Modbus library for Idealclima fan coil units (Comfosplit IKARO HW and Radiantore SKUDO DC Inverter)
5
+ Project-URL: Homepage, https://github.com/crug80/idealclima-modbus
6
+ Project-URL: Issues, https://github.com/crug80/idealclima-modbus/issues
7
+ Author-email: crug80 <claudio@cr-tech.it>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: home-assistant,hvac,idealclima,ikaro,modbus,skudo
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Topic :: Home Automation
18
+ Classifier: Typing :: Typed
19
+ Requires-Python: >=3.13
20
+ Requires-Dist: modbus-connection>=4.12.7
21
+ Provides-Extra: tmodbus
22
+ Requires-Dist: modbus-connection[tmodbus]>=4.12.7; extra == 'tmodbus'
23
+ Description-Content-Type: text/markdown
24
+
25
+ # idealclima-modbus
26
+
27
+ Async Python library for controlling Idealclima Modbus fan coil units ([**Comfosplit IKARO HW**](https://www.idealclima.eu/it/radiantori/terminali-idronici/ikaro) and [**Radiantore SKUDO DC Inverter**](https://www.idealclima.eu/it/radiantori/terminali-idronici/radiantore-skudo-dc-inverter)), built on [`modbus-connection`](https://github.com/home-assistant-libs/modbus-connection) for Home Assistant Core integrations and standalone use.
28
+
29
+ ## Requirements & Notes
30
+
31
+ - **Modbus Unit Address**: Units ship with default Modbus address `15`, which only allows changing the address. **You must assign a unique address** (`1–32`) to each unit before using this library.
32
+ - **Serial Settings**: `9600 bps`, `8N1`.
33
+ - **Write Function**: Both models only support Modbus function `0x10` (Write Multiple Registers), which is enforced automatically via `force_fc16=True`.
34
+
35
+ ## Installation
36
+
37
+ For Home Assistant or when providing your own `ModbusUnit`:
38
+
39
+ ```bash
40
+ pip install idealclima-modbus
41
+ ```
42
+
43
+ For standalone usage with `tmodbus`:
44
+
45
+ ```bash
46
+ pip install "idealclima-modbus[tmodbus]"
47
+ ```
48
+
49
+ ## Usage
50
+
51
+ ```python
52
+ import asyncio
53
+ from modbus_connection import ModbusSerialParams
54
+ from modbus_connection.tmodbus import ModbusConnection
55
+ from idealclima_modbus import FanSpeed, IkaroHW, IkaroMode
56
+
57
+ async def main() -> None:
58
+ conn = ModbusConnection(
59
+ ModbusSerialParams(device="/dev/ttyUSB0", baudrate=9600)
60
+ )
61
+ async with conn:
62
+ unit = conn.for_unit(20)
63
+ ikaro = IkaroHW(unit)
64
+ await ikaro.async_update()
65
+ print(ikaro.readings.ambient_temperature)
66
+ await ikaro.async_set_mode(IkaroMode.COOL)
67
+ await ikaro.async_set_fan_speed(FanSpeed.LOW)
68
+ await ikaro.async_set_power(True)
69
+
70
+ asyncio.run(main())
71
+ ```
@@ -0,0 +1,47 @@
1
+ # idealclima-modbus
2
+
3
+ Async Python library for controlling Idealclima Modbus fan coil units ([**Comfosplit IKARO HW**](https://www.idealclima.eu/it/radiantori/terminali-idronici/ikaro) and [**Radiantore SKUDO DC Inverter**](https://www.idealclima.eu/it/radiantori/terminali-idronici/radiantore-skudo-dc-inverter)), built on [`modbus-connection`](https://github.com/home-assistant-libs/modbus-connection) for Home Assistant Core integrations and standalone use.
4
+
5
+ ## Requirements & Notes
6
+
7
+ - **Modbus Unit Address**: Units ship with default Modbus address `15`, which only allows changing the address. **You must assign a unique address** (`1–32`) to each unit before using this library.
8
+ - **Serial Settings**: `9600 bps`, `8N1`.
9
+ - **Write Function**: Both models only support Modbus function `0x10` (Write Multiple Registers), which is enforced automatically via `force_fc16=True`.
10
+
11
+ ## Installation
12
+
13
+ For Home Assistant or when providing your own `ModbusUnit`:
14
+
15
+ ```bash
16
+ pip install idealclima-modbus
17
+ ```
18
+
19
+ For standalone usage with `tmodbus`:
20
+
21
+ ```bash
22
+ pip install "idealclima-modbus[tmodbus]"
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```python
28
+ import asyncio
29
+ from modbus_connection import ModbusSerialParams
30
+ from modbus_connection.tmodbus import ModbusConnection
31
+ from idealclima_modbus import FanSpeed, IkaroHW, IkaroMode
32
+
33
+ async def main() -> None:
34
+ conn = ModbusConnection(
35
+ ModbusSerialParams(device="/dev/ttyUSB0", baudrate=9600)
36
+ )
37
+ async with conn:
38
+ unit = conn.for_unit(20)
39
+ ikaro = IkaroHW(unit)
40
+ await ikaro.async_update()
41
+ print(ikaro.readings.ambient_temperature)
42
+ await ikaro.async_set_mode(IkaroMode.COOL)
43
+ await ikaro.async_set_fan_speed(FanSpeed.LOW)
44
+ await ikaro.async_set_power(True)
45
+
46
+ asyncio.run(main())
47
+ ```
@@ -0,0 +1,77 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "idealclima-modbus"
7
+ version = "0.2.0"
8
+ description = "Async Modbus library for Idealclima fan coil units (Comfosplit IKARO HW and Radiantore SKUDO DC Inverter)"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.13"
12
+ authors = [
13
+ { name = "crug80", email="claudio@cr-tech.it" },
14
+ ]
15
+ keywords = ["idealclima", "modbus", "home-assistant", "ikaro", "skudo", "hvac"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.13",
22
+ "Programming Language :: Python :: 3.14",
23
+ "Topic :: Home Automation",
24
+ "Typing :: Typed",
25
+ ]
26
+ dependencies = [
27
+ "modbus-connection>=4.12.7",
28
+ ]
29
+
30
+ [project.optional-dependencies]
31
+ tmodbus = [
32
+ "modbus-connection[tmodbus]>=4.12.7",
33
+ ]
34
+
35
+ [project.urls]
36
+ Homepage = "https://github.com/crug80/idealclima-modbus"
37
+ Issues = "https://github.com/crug80/idealclima-modbus/issues"
38
+
39
+ [dependency-groups]
40
+ dev = [
41
+ "mypy>=2.0",
42
+ "pytest>=9.0",
43
+ "pytest-asyncio>=0.25",
44
+ "pytest-cov>=7.0",
45
+ "ruff>=0.15",
46
+ ]
47
+
48
+ [tool.hatch.build.targets.wheel]
49
+ packages = ["src/idealclima_modbus"]
50
+
51
+ [tool.pytest.ini_options]
52
+ testpaths = ["tests"]
53
+ asyncio_default_fixture_loop_scope = "function"
54
+
55
+ [tool.mypy]
56
+ python_version = "3.13"
57
+ strict = true
58
+ warn_unreachable = true
59
+ packages = ["idealclima_modbus"]
60
+ mypy_path = "src"
61
+
62
+ [tool.ruff]
63
+ target-version = "py313"
64
+ src = ["src", "tests"]
65
+
66
+ [tool.ruff.lint]
67
+ select = [
68
+ "E",
69
+ "F",
70
+ "W",
71
+ "I",
72
+ "UP",
73
+ "B",
74
+ "SIM",
75
+ "ASYNC",
76
+ "RUF",
77
+ ]
@@ -0,0 +1,18 @@
1
+ """Async Modbus library for Idealclima fan coil units."""
2
+
3
+ from .enums import FanSpeed, IkaroMode, SkudoMode, TemperatureUnit
4
+ from .ikaro import IkaroHW, IkaroReadings, IkaroSettings
5
+ from .skudo import SkudoDCInverter, SkudoReadings, SkudoSettings
6
+
7
+ __all__ = [
8
+ "FanSpeed",
9
+ "IkaroHW",
10
+ "IkaroMode",
11
+ "IkaroReadings",
12
+ "IkaroSettings",
13
+ "SkudoDCInverter",
14
+ "SkudoMode",
15
+ "SkudoReadings",
16
+ "SkudoSettings",
17
+ "TemperatureUnit",
18
+ ]
@@ -0,0 +1,85 @@
1
+ """Shared base components and device logic for Idealclima units."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from modbus_connection import ModbusUnit
6
+ from modbus_connection.model import (
7
+ Component,
8
+ Device,
9
+ UpdateReport,
10
+ boolean,
11
+ enum,
12
+ gauge,
13
+ )
14
+
15
+ from .enums import FanSpeed
16
+
17
+
18
+ class BaseIdealclimaReadings(Component):
19
+ """Common input registers shared by Idealclima fan coil units."""
20
+
21
+ register_space = "input"
22
+
23
+ ambient_temperature = gauge(46801, 0.1, signed=True, unit="°C")
24
+
25
+
26
+ class BaseIdealclimaSettings(Component):
27
+ """Common holding registers shared by Idealclima fan coil units."""
28
+
29
+ register_space = "holding"
30
+ max_gap = 0
31
+
32
+ power = boolean(28301, writable=True, force_fc16=True)
33
+ fan_speed = enum(28303, FanSpeed, signed=True, writable=True, force_fc16=True)
34
+ target_temp_cool = gauge(
35
+ 28310, 0.1, signed=True, writable=True, unit="°C", force_fc16=True
36
+ )
37
+ target_temp_heat = gauge(
38
+ 28311, 0.1, signed=True, writable=True, unit="°C", force_fc16=True
39
+ )
40
+
41
+
42
+ class BaseIdealclimaDevice[
43
+ R: BaseIdealclimaReadings,
44
+ S: BaseIdealclimaSettings,
45
+ ](Device):
46
+ """Base device wrapping readings and settings components."""
47
+
48
+ readings: R
49
+ settings: S
50
+
51
+ def __init__(self, unit: ModbusUnit, readings: R, settings: S) -> None:
52
+ """Initialize the device with a shared Modbus unit and its components."""
53
+ super().__init__(unit)
54
+ self.readings = readings
55
+ self.settings = settings
56
+
57
+ async def async_update_readings(self) -> UpdateReport:
58
+ """Poll input registers (live sensor readings)."""
59
+ return await self.async_poll(("readings",))
60
+
61
+ async def async_update_settings(self) -> UpdateReport:
62
+ """Poll holding registers (configuration and setpoints)."""
63
+ return await self.async_poll(("settings",))
64
+
65
+ async def async_update(self) -> UpdateReport:
66
+ """Poll both readings and settings."""
67
+ return await self.async_poll(("readings", "settings"))
68
+
69
+ async def _async_set_power(self, enabled: bool, *, stop_fan: bool) -> None:
70
+ """Set unit power and optionally stop the fan when turning off."""
71
+ await self.settings.write("power", enabled)
72
+ if not enabled and stop_fan:
73
+ await self.settings.write("fan_speed", FanSpeed.OFF)
74
+
75
+ async def async_set_fan_speed(self, speed: FanSpeed) -> None:
76
+ """Set the target fan speed (register 28303)."""
77
+ await self.settings.write("fan_speed", speed)
78
+
79
+ async def async_set_target_temp_cool(self, temperature: float) -> None:
80
+ """Set the cooling target temperature in °C (register 28310)."""
81
+ await self.settings.write("target_temp_cool", temperature)
82
+
83
+ async def async_set_target_temp_heat(self, temperature: float) -> None:
84
+ """Set the heating target temperature in °C (register 28311)."""
85
+ await self.settings.write("target_temp_heat", temperature)
@@ -0,0 +1,43 @@
1
+ """Enumerations for Idealclima Modbus fan coil units."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from enum import IntEnum
6
+
7
+
8
+ class FanSpeed(IntEnum):
9
+ """Fan speed values for holding register 28303."""
10
+
11
+ OFF = 0
12
+ SUPER_SILENCE = 1
13
+ LOW = 2
14
+ MEDIUM = 3
15
+ HIGH = 4
16
+ AUTO = 6
17
+
18
+
19
+ class IkaroMode(IntEnum):
20
+ """Operating mode values for Comfosplit IKARO HW (register 28302)."""
21
+
22
+ OFF = 0
23
+ COOL = 1
24
+ DRY = 2
25
+ FAN_ONLY = 3
26
+ HEAT = 4
27
+
28
+
29
+ class SkudoMode(IntEnum):
30
+ """Operating mode values for Radiantore SKUDO DC Inverter (register 28302)."""
31
+
32
+ AUTO = 0
33
+ COOL = 1
34
+ DRY = 2
35
+ FAN_ONLY = 3
36
+ HEAT = 4
37
+
38
+
39
+ class TemperatureUnit(IntEnum):
40
+ """Display temperature unit for SKUDO DC Inverter (register 28319)."""
41
+
42
+ CELSIUS = 0
43
+ FAHRENHEIT = 1
@@ -0,0 +1,39 @@
1
+ """Comfosplit IKARO HW Modbus device model."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from modbus_connection import ModbusUnit
6
+ from modbus_connection.model import enum
7
+
8
+ from .base import (
9
+ BaseIdealclimaDevice,
10
+ BaseIdealclimaReadings,
11
+ BaseIdealclimaSettings,
12
+ )
13
+ from .enums import IkaroMode
14
+
15
+
16
+ class IkaroReadings(BaseIdealclimaReadings):
17
+ """Input registers for Comfosplit IKARO HW."""
18
+
19
+
20
+ class IkaroSettings(BaseIdealclimaSettings):
21
+ """Holding registers for Comfosplit IKARO HW."""
22
+
23
+ mode = enum(28302, IkaroMode, signed=True, writable=True, force_fc16=True)
24
+
25
+
26
+ class IkaroHW(BaseIdealclimaDevice[IkaroReadings, IkaroSettings]):
27
+ """Comfosplit IKARO HW fan coil unit."""
28
+
29
+ def __init__(self, unit: ModbusUnit) -> None:
30
+ """Initialize an IKARO HW device bound to a ModbusUnit."""
31
+ super().__init__(unit, IkaroReadings(unit), IkaroSettings(unit))
32
+
33
+ async def async_set_power(self, enabled: bool, *, stop_fan: bool = True) -> None:
34
+ """Turn the unit on or off; stops the fan by default when turning off."""
35
+ await self._async_set_power(enabled, stop_fan=stop_fan)
36
+
37
+ async def async_set_mode(self, mode: IkaroMode) -> None:
38
+ """Set the operating mode (register 28302)."""
39
+ await self.settings.write("mode", mode)