Skip to main content

Python library to interact with Mitsubishi Heavy Industries HVAC systems

Project description

pymhihvac

PyPI Python License

A Python library for controlling Mitsubishi Heavy Industries (MHI) HVAC systems via their local API using a SC-SL4 central control unit. Built especiallty for Home Assistant, enable the creation of climate, sensor and binary sensor entities. It can also be used standalone.

Features

  • Full HVAC Control:
    • Power on/off
    • Set temperature (18-30°C)
    • Adjust fan speeds (Low/Medium/High/Diffuse)
    • Control swing modes (Auto/Stop1-4)
    • Set HVAC modes (Cool/Dry/Fan/Heat/Fan Only)
  • Status Monitoring:
    • Current room temperature
    • Filter status
    • Remote control lock state
  • Management
    • Filter reset
  • Virtual Groups: Manage multiple units as a single entity
  • Async Support: Built on aiohttp for efficient communication

Installation

pip install pymhihvac

Quick Start

import asyncio
from pymhihvac.controller import MHIHVACSystemController
from pymhihvac.device import MHIHVACDeviceData

async def main():
    # Initialize controller
    controller = MHIHVACSystemController(
        host="192.168.1.100",  # HVAC system IP
        username="admin",
        password="password"
    )

    # Login to API
    await controller.async_login()

    # Fetch raw_data devices
    raw_data = await controller.async_update_data(
      method="all",               # "all" (Default) = all valid units, "block" = "units in configured blocks"
      include_index="['1','2']",  # (Optional) The index of the blocks to include
      include_groups="['1','2']", # (Optional) The 'GroupNo' of the units to include
    )

    # Fetch all devices and virtual groups from API raw_data
    devices_data: list[
        MHIHVACDeviceData
    ] = parse_raw_data(
        raw_data_list,
        virtual_group_config,
    )

    # Control first device
    device = devices[0]
    print(f"Controlling: {device.group_name} ({device.group_no})")

    # Turn on cooling at 22°C
    await controller.async_set_hvac_mode(device, "cool")
    await controller.async_set_target_temperature(device, 22.0)

asyncio.run(main())

Configuration (Example)

Optionally you can create a YAML to store configuration and use yaml.load(...) to build a dictionary:

configuration:
  data_fetching:
    method: "all"
    include_index: ["1", "2"]
    include_groups: ["1", "2"]
  virtual_groups:
    129:
      name: "Living Room Group"
      units: ["1", "2"]  # Group numbers from physical units
    130:
      name: "Entire Floor"
      units: "all"       # Include all available units

API Reference

Core Classes

MHIHVACSystemController

Main interface for HVAC communication:

controller = MHIHVACSystemController(
    host: str,          # HVAC system IP/hostname
    username: str,      # API username
    password: str,      # API password
    session: ClientSession = None  # Optional aiohttp session
)

Key Methods:

Method Description
async_login() Establish API session
async_update_data() Fetch current device states
async_set_hvac_mode(device, mode) Set HVAC mode with auto On/Off
async_set_hvac_set_mode(device, mode) Set HVAC mode
async_turn_hvac_on (device) Turn HVAC on
async_turn_hvac_off(device) Turn HVAC off
async_set_target_temperature(device, temp) Set target temperature
async_set_fan_mode(device, mode) Set fan speed
async_set_swing_mode(device, mode) Set swing position
async_set_rc_lock(device,mode) Set the RC lock mode
async_filter_reset() Reset the Filter Signal
set_device_property(device,properties,values) Set any properties
async_close_session() Close the session if not passed to the controller

MHIHVACDeviceData

Dataclass representing HVAC unit/group:
@dataclass
class MHIHVACDeviceData:
    group_no: str | None          # Physical group number
    group_name: str | None        # Display name
    is_virtual: bool              # True for virtual groups
    current_temperature: float | None
    target_temperature: float | None
    hvac_mode: str | None         # Current operation mode
    fan_mode: str | None          # Current fan speed
    swing_mode: str | None        # Current swing position
    is_filter_sign: bool          # Filter needs maintenance
    rc_lock: bool                 # Remote control locked

Mode Mappings

HVAC Modes:

Home Assistant MHI API Value
off -
cool 2
dry 3
fan_only 4
heat 5

Fan Modes:

Home Assistant MHI API Value
low 1
medium 2
high 3
diffuse 4

Swing Modes:

Home Assistant MHI API Value
auto 1
stop1 2
stop2 3
stop3 4
stop4 5

Filter Sign:

Home Assistant MHI API Value
clean 0
dirty 1

RC Lock:

Home Assistant MHI API Value
locked 222
unlocked 111

Requirements

  • Python 3.9+

  • aiohttp >= 3.8.0

  • voluptuous >= 0.13.0

Contributing

  1. Fork the repository

  2. Create a feature branch (git checkout -b feature/your-feature)

  3. Commit changes (git commit -am 'Add awesome feature')

  4. Push to branch (git push origin feature/your-feature)

  5. Open a Pull Request

License

MIT


Disclaimer: This project is not affiliated with or endorsed by Mitsubishi Heavy Industries. Use at your own risk. Always ensure proper HVAC system configuration before deployment.

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

pymhihvac-0.1.0.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

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

pymhihvac-0.1.0-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file pymhihvac-0.1.0.tar.gz.

File metadata

  • Download URL: pymhihvac-0.1.0.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for pymhihvac-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3d6097fc7b42922df131d5b225729f1cd0a9ef8196e82821dbb9cd056da35608
MD5 0e15f819bc475aa60c9565ab98d7417b
BLAKE2b-256 8d282b5a5d2d26c85b1b4f35860190f700dd872d64452a4490e410e7838010d9

See more details on using hashes here.

File details

Details for the file pymhihvac-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pymhihvac-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for pymhihvac-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23c92fb6544257f722b084426f94581bba666bf6ea53f84d8169515064644012
MD5 7c6d8d696d82296e787acf6731f98bfb
BLAKE2b-256 fcee35ebaae7e9cc14f9b2ffbc68d990f8090a677829e1d1be64e9bb608e52af

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