This script acts as a bridge between an IHC system and an MQTT broker, enabling Home Assistant to control and monitor IHC-based outputs and inputs via MQTT.
It connects to the IHCServer using a WebSocket and exposes all input/output states over MQTT. It also listens for MQTT commands to control outputs on the IHC system. This makes it possible to integrate older Danish IHC systems into modern smart home platforms like Home Assistant.
The bridge runs on a Raspberry Pi alongside the IHCServer and is resilient, logging all activity and reconnecting automatically in case of failures.
- A Raspberry Pi - I used an old Rpi 1 so any model will do
- USB to RS485 adapter (often available on AliExpress for ~$1, and they usually work fine)
- IHC controller
- Installed and running IHCServer
- MQTT broker (e.g., EMQX installed via the Home Assistant Add-on store)
- Home Assistant (optional, but recommended)
-
Follow these guides to get your IHC server up and running:
-
Clone this repository to the
/optfolder:cd /opt git clone https://github.com/JAQ0B/IHCBridge.git -
Install required Python packages
Run the following commands to install the dependencies in a vertual environment:
# Install venv if you don’t have it sudo apt update sudo apt install python3-venv # Navigate to the project folder cd /opt/IHCBridge # Create a virtual environment python3 -m venv venv # Activate the virtual environment source venv/bin/activate # Install dependencies inside the virtual environment pip install -r requirements.txt -
Edit
IHCBridge.pyto match your setupOpen the file and change the following:
-
self.ihc_host: Set this to the IP address of the device running the IHCServer (usually the same Pi). -
self.mqtt_host: Set this to the IP address of your MQTT broker. -
If your MQTT credentials differ from the default, update the line:
self.mqtt_client.username_pw_set("USERNAME", "PASSWORD")Or remove it if your broker doesn’t require authentication.
-
-
Create the service file for the IHC MQTT Bridge
File path:
/etc/systemd/system/ihc-bridge.service[Unit] Description=IHC MQTT Bridge After=network.target [Service] ExecStart=/opt/IHCBridge/venv/bin/python /opt/IHCBridge/IHCBridge.py Restart=always RestartSec=10 [Install] WantedBy=multi-user.target -
Create the service file for the IHCServer
File path:
/etc/systemd/system/ihcserver.service[Unit] Description=IHC server daemon [Service] Type=simple ExecStart=/opt/ihcserver/ihcserver -d StandardOutput=null Restart=always RestartSec=2 [Install] WantedBy=sysinit.target -
Enable and start both services
Run the following commands:
sudo systemctl daemon-reexec sudo systemctl daemon-reload sudo systemctl enable ihcserver sudo systemctl enable ihc-bridge sudo systemctl start ihcserver sudo systemctl start ihc-bridge -
View the IHC Bridge log if needed
Use this command to tail the log file:
tail -f /opt/ihc_bridge.log
- Install the EMQX broker from the Home Assistant Add-on store.
- Use the MQTT integration in Home Assistant to connect to your EMQX broker.
In your configuration.yaml file, add:
mqtt:
switch: !include mqtt_switches.yaml
light: !include mqtt_lights.yaml
binary_sensor: !include mqtt_binary_sensors.yaml
This tells Home Assistant to load switches, lights, and binary sensors from separate files for better organization.
Create separate files for different device types:
mqtt_switches.yamlfor switchesmqtt_lights.yamlfor lightsmqtt_binary_sensors.yamlfor inputs (sensors, buttons, etc.)
Each output (light or switch) must be manually added based on your IHC module layout.
# Module 1, Output 2 example
- unique_id: ihc_output_1_2
name: "Dinner Table"
state_topic: "ihc/outputState/1/2/state"
command_topic: "ihc/output/1/2/set"
payload_on: "ON"
payload_off: "OFF"
Note: Input support is implemented in the bridge code but has not been personally tested. It should work based on the code implementation.
# Module 1, Input 3 - Motion Sensor example
- unique_id: ihc_input_1_3
name: "Living Room Motion"
state_topic: "ihc/inputState/1/3/state"
payload_on: "ON"
payload_off: "OFF"
device_class: motion
# Module 1, Input 4 - Door Contact example
- unique_id: ihc_input_1_4
name: "Front Door"
state_topic: "ihc/inputState/1/4/state"
payload_on: "ON"
payload_off: "OFF"
device_class: door
# Module 2, Input 1 - Push Button example
- unique_id: ihc_input_2_1
name: "Hallway Button"
state_topic: "ihc/inputState/2/1/state"
payload_on: "ON"
payload_off: "OFF"
Outputs (Switches/Lights):
- State topic:
ihc/outputState/{module}/{output}/state - Command topic:
ihc/output/{module}/{output}/set(for sending commands) - Use
switchorlightin Home Assistant
Inputs (Binary Sensors):
- State topic:
ihc/inputState/{module}/{input}/state - No command topic (read-only)
- Use
binary_sensorin Home Assistant - Can use device classes like
motion,door,window,button, etc.
unique_id: Should be globally unique. Recommended format:ihc_output_<module>_<number>for outputs,ihc_input_<module>_<number>for inputs.name: The friendly name shown in the Home Assistant UI.state_topic: The MQTT topic the bridge uses to publish the current state.command_topic: The topic that sends commands back to the bridge (outputs only).payload_on/payload_off: Strings to represent on/off states.device_class: For binary sensors, use appropriate classes for better UI icons and behavior.
Repeat for all relevant outputs and inputs by adjusting the module/output/input numbers and names.
After saving the YAML files, restart Home Assistant.
You should now see all of your IHC devices appear as native entities in the dashboard.
- The bridge reconnects automatically and handles failure cases (MQTT down, IHC server restart, etc.).
- You can also trigger IHC or Raspberry Pi restarts via MQTT by sending
"RESTART"to:ihc/system/restart– restarts IHC serverihc/system/pi_restart– reboots the Pi
These can be used in Home Assistant automations or manually via MQTT.
This project is licensed under the MIT License.
See the LICENSE file for details.
This project is shared to help others integrate IHC with Home Assistant.
While it’s not actively developed, pull requests and improvements are always welcome!