Arie/sabik

★ 0Forks 1RubyGitHub ↗Compare

README

Sabik 350 Modbus Control

Control and monitor a Sabik 350 ventilation unit via Modbus and MQTT, allowing integration with Home Assistant.

Prerequisites

  • USB-Modbus converter connected to the Sabik
  • MQTT broker (typically Home Assistant's built-in broker)

Running with Docker (Recommended)

  1. Add your user to the dialout group for USB access:
sudo usermod -a -G dialout $USER
# Log out and back in for changes to take effect
  1. Clone and build:
git clone https://github.com/Arie/sabik
cd sabik
docker compose build
  1. Edit docker-compose.yml to set your MQTT credentials and USB device path (default is /dev/ttyUSB0).

  2. Run:

docker compose up -d

This will automatically set up the sensors in Home Assistant and start the MQTT subscriber.

  1. View logs:
docker compose logs -f

Manual Installation

  1. Clone the repository:
git clone https://github.com/Arie/sabik
cd sabik
  1. Install dependencies:
gem install bundler && bundle
  1. Create a MQTT user in Home Assistant if you don't already have one

  2. Create a secrets.rb file with your MQTT credentials:

MQTT_USER = 'your-ha-mqtt-user-here'
MQTT_PASSWORD = 'your-ha-mqtt-user-password-here'
MQTT_HOST = 'ip-address-or-hostname-of-ha-mqtt'

Initial Setup

  1. Create the sensors in Home Assistant:
ruby setup_mqtt.rb
  1. Test the Modbus connection:
bundle console

Then in the console:

require_relative 'sabik'
Sabik.new.status

You should see output like this:

{:active_alarms=>0,
 :filter_alarm=>0,
 :temperature_sensor_extract_air_status=>0,
 # ... more status values ...
 :selected_air_volume=>1}

Running the MQTT Subscriber

Manual Start

ruby mqtt_subscriber.rb

As a Systemd User Service

  1. Create the systemd user directory:
mkdir -p ~/.config/systemd/user/
  1. Create ~/.config/systemd/user/sabik-mqtt.service:
[Unit]
Description=Sabik MQTT Control Service
After=network.target

[Service]
Type=simple
Environment="MQTT_HOST=your-ha-mqtt-host"
Environment="MQTT_USER=your-ha-mqtt-user"
Environment="MQTT_PASSWORD=your-ha-mqtt-password"
WorkingDirectory=%h/path/to/sabik
ExecStart=/usr/bin/ruby mqtt_subscriber.rb
Restart=always
RestartSec=10

[Install]
WantedBy=default.target
  1. Enable and start the service:
# Enable service
systemctl --user enable sabik-mqtt.service

# Start service
systemctl --user start sabik-mqtt.service

# Check status
systemctl --user status sabik-mqtt.service

Testing and Control

Use the test script for manual control:

ruby test_mqtt_control.rb

Features available through the test script:

  • Operation modes (off/auto/manual)
  • Fan speeds (low/medium/high/auto/snooze)
  • Bypass temperature settings:
    • Minimum indoor temperature (21-30°C)
    • Minimum outdoor temperature (12-20°C)
    • Minimum temperature difference (3-6°C)
  • Manual and automatic bypass control
  • Summer mode control
  • Boost mode
  • Time settings and synchronization
  • Status monitoring

Temperature-Dependent Features

Bypass Mode

Bypass requires all these conditions:

  • Indoor (Extract) temperature > minimum (default 23°C)
  • Outdoor temperature > minimum (default 13°C)
  • Temperature difference > minimum (default 3°C)

Summer Mode

Requires:

  • Outdoor temperature above minimum (uses same threshold as bypass)

Troubleshooting

  1. Serial Port Access:
# Add user to dialout group
sudo usermod -a -G dialout $USER
# Verify permissions
ls -l /dev/ttyUSB0
  1. View Service Logs:
journalctl --user -u sabik-mqtt.service -f
  1. Test MQTT Connection:
mosquitto_sub -h your-ha-mqtt-host -u your-mqtt-user -P your-mqtt-password -t 'homeassistant/climate/sabik/#'

Contributors

Arie

Issues