Skip to content

Commit

Permalink
Merge pull request #14 from michaelarnauts/comfocool
Browse files Browse the repository at this point in the history
Comfocool
  • Loading branch information
michaelarnauts authored Nov 9, 2023
2 parents 0ec46f7 + db5d559 commit c8bf1a7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
28 changes: 28 additions & 0 deletions aiocomfoconnect/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ async def main(args):
elif args.action == "set-mode":
await run_set_mode(args.host, args.uuid, args.mode)

elif args.action == "set-comfocool":
await run_set_comfocool(args.host, args.uuid, args.mode)

elif args.action == "show-sensors":
await run_show_sensors(args.host, args.uuid)

Expand Down Expand Up @@ -168,6 +171,26 @@ async def run_set_mode(host: str, uuid: str, mode: Literal["auto", "manual"]):
await comfoconnect.disconnect()


async def run_set_comfocool(host: str, uuid: str, mode: Literal["auto", "off"]):
"""Set comfocool mode."""
# Discover bridge so we know the UUID
bridges = await discover_bridges(host)
if not bridges:
raise Exception("No bridge found")

# Connect to the bridge
comfoconnect = ComfoConnect(bridges[0].host, bridges[0].uuid)
try:
await comfoconnect.connect(uuid)
except ComfoConnectNotAllowed:
print("Could not connect to bridge. Please register first.")
sys.exit(1)

await comfoconnect.set_comfocool_mode(mode)

await comfoconnect.disconnect()


async def run_show_sensors(host: str, uuid: str):
"""Show all sensors."""
# Discover bridge so we know the UUID
Expand Down Expand Up @@ -317,6 +340,11 @@ async def run_get_property(host: str, uuid: str, node_id: int, unit: int, subuni
p_set_mode.add_argument("--host", help="Host address of the bridge")
p_set_mode.add_argument("--uuid", help="UUID of this app", default=DEFAULT_UUID)

p_set_mode = subparsers.add_parser("set-comfocool", help="set comfocool mode")
p_set_mode.add_argument("mode", help="Comfocool mode", choices=["auto", "off"])
p_set_mode.add_argument("--host", help="Host address of the bridge")
p_set_mode.add_argument("--uuid", help="UUID of this app", default=DEFAULT_UUID)

p_sensors = subparsers.add_parser("show-sensors", help="show the sensor values")
p_sensors.add_argument("--host", help="Host address of the bridge")
p_sensors.add_argument("--uuid", help="UUID of this app", default=DEFAULT_UUID)
Expand Down
14 changes: 14 additions & 0 deletions aiocomfoconnect/comfoconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
SUBUNIT_01,
SUBUNIT_02,
SUBUNIT_03,
SUBUNIT_05,
SUBUNIT_06,
SUBUNIT_07,
SUBUNIT_08,
Expand Down Expand Up @@ -310,6 +311,19 @@ async def set_away(self, mode: bool, timeout=3600):
else:
await self.cmd_rmi_request(bytes([0x85, UNIT_SCHEDULE, SUBUNIT_01, 0x0B]))

async def get_comfocool_mode(self):
"""Get the current comfocool mode."""
result = await self.cmd_rmi_request(bytes([0x83, UNIT_SCHEDULE, SUBUNIT_05, 0x01]))
mode = result.message[0]
return mode == 0

async def set_comfocool_mode(self, mode: Literal["auto", "off"], timeout=-1):
"""Set the comfocool mode (auto / off)."""
if mode == "auto":
await self.cmd_rmi_request(bytes([0x85, UNIT_SCHEDULE, SUBUNIT_05, 0x01]))
else:
await self.cmd_rmi_request(bytestring([0x84, UNIT_SCHEDULE, SUBUNIT_05, 0x01, 0x00, 0x00, 0x00, 0x00, timeout.to_bytes(4, "little", signed=True), 0x00]))

async def get_temperature_profile(self):
"""Get the temperature profile (warm / normal / cool)."""
result = await self.cmd_rmi_request(bytes([0x83, UNIT_SCHEDULE, SUBUNIT_03, 0x01]))
Expand Down
4 changes: 2 additions & 2 deletions aiocomfoconnect/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
from dataclasses import dataclass
from typing import Callable, Dict

from .util import calculate_airflow_constraints
from .const import (
TYPE_CN_BOOL,
TYPE_CN_INT16,
TYPE_CN_INT64,
TYPE_CN_UINT8,
TYPE_CN_UINT16,
TYPE_CN_UINT32,
TYPE_CN_INT64,
)
from .util import calculate_airflow_constraints

# Sensors
SENSOR_ANALOG_INPUT_1 = 369
Expand Down
1 change: 1 addition & 0 deletions docs/PROTOCOL-RMI.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ factory mode or tries to perform an update.)
| 0x01 | 0x0b | AWAY |
| 0x02 | 0x01 | Bypass control (auto/on/off) |
| 0x03 | 0x01 | Temperature profile (warm/normal/cool) |
| 0x05 | 0x01 | Comfocool control |
| 0x06 | 0x01 | Supply fan control |
| 0x07 | 0x01 | Exhaust fan control |
| 0x08 | 0x01 | Ventilation mode (auto/manual) |
Expand Down

0 comments on commit c8bf1a7

Please sign in to comment.