Coder Social home page Coder Social logo

abildgren / comfoair-mqtt-bridge Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mtdcr/comfoair-mqtt-bridge

0.0 0.0 0.0 42 KB

A bridge between Zehnder ComfoAir ventilation units and MQTT with support for Home Assistant

License: MIT License

Python 100.00%

comfoair-mqtt-bridge's Introduction

A bridge between Zehnder ComfoAir ventilation units and MQTT with support for Home Assistant

This program receives events from a ComfoAir connected to a serial port and publishes contained data on MQTT. It also subscribes to commands from MQTT and relays them to the ventilation unit.

Currently it assumes presence of a CC-Ease control unit. It's able to switch between CC-Ease- and PC-Modes quite reliably on demand.

Tested devices:

Home Assistant, when configured for MQTT discovery, can auto-detect fans and sensors published by this program.

Dependencies

How to use

  • Using a real serial port:
comfoair-mqtt-bridge.py --broker mqtt://broker.local --port /dev/ttyUSB0
  • With a serial port reachable over tcp, e.g. using ser2net:
comfoair-mqtt-bridge.py --broker mqtt://broker.local --port socket://sbc.local:51765

When used in combination with Home Assistant, add the --hass option.

To see debug messages, add --debug.

Instead of specifying broker and port on the command-line, you can store them in a configuration file (option --config, default path: /var/lib/comfoair-mqtt-bridge/config.json).

A /etc/ser2net.conf should look similar to this one:

192.168.3.50,51765:raw:0:/dev/serial/by-id/usb-067b_2303-if00-port0:9600 8DATABITS NONE 1STOPBIT -XONXOFF -RTSCTS -HANGUP_WHEN_DONE

Running the bridge as a systemd service

Save this file as /etc/systemd/system/comfoair-mqtt-bridge.service:

[Unit]
Description=ComfoAir-MQTT-Bridge
After=network-online.target

[Service]
Type=simple
ExecStart=/srv/homeassistant/bin/python /usr/local/bin/comfoair-mqtt-bridge.py --broker mqtt://broker.local --port /dev/ttyUSB0 --hass
Restart=on-failure
RestartSec=5s
DynamicUser=yes
StateDirectory=comfoair-mqtt-bridge
DevicePolicy=closed
DeviceAllow=char-ttyUSB
SupplementaryGroups=dialout

[Install]
WantedBy=multi-user.target

Edit paths and URLs to match your setup. In this example, /srv/homeassistant is a Python venv, into which the dependencies were installed using pip.

Then enable and start the service:

systemctl enable comfoair-mqtt-bridge.service
systemctl start comfoair-mqtt-bridge.service

Notes regarding MQTT

  • username/password are passed as part of the --broker parameter, e.g. --broker mqtt://username:[email protected]

Notes regarding Home Assistant

  • Home Assistant will auto-detect a device with multiple entities (currently fan.comfoair and some sensors).
  • All entities get marked as unavailable if the bridge gets shutdown cleanly (SIGINT, SIGTERM) or if there's no data on the serial line.
  • You can emulate a pressed button on the CC-Ease.
    • Each key resembles one bit: 1=fan, 2=mode, 4=clock, 8=temp, 16=plus, 32=minus
    • To press multiple keys at the same time, sum up their values. Example: fan + mode = 3
    • You can either send a short key press by publishing the keys_short attribute, or a long key press by publishing the keys_long attribute on MQTT.
    • Pressing the mode key toggles between three operating modes:
      • Supply + Exhaust
      • Exhaust only
      • Supply only
    • What follows is an example for a tap_action in Lovelace to send a short mode key press event to your ventilation unit. The topic gets derived from your command-line parameters. To find it in Home Assistant, open Configuration -> Devices -> ComfoAir -> MQTT INFO and look for Subscribed Topics. Then replace e.g. availability with keys_short.
"tap_action": {
  "action": "call-service",
  "service": "mqtt.publish",
  "service_data": {
    "payload": 2,
    "retain": false,
    "topic": "ComfoAir/sbc.local:51765/keys_short"
  }
}

comfoair-mqtt-bridge's People

Contributors

kayman-mk avatar mtdcr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.