8000 GitHub - kobbejager/otgw: Python OTGW MQTT bridge
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

kobbejager/otgw

 
 

Repository files navigation

Python OTGW MQTT bridge

This package allows for communication between an OpenTherm Gateway, running the firmware by Schelte Bron and an MQTT service. It was tested using Home Assistant's built-in MQTT broker.

Supported OTGW gateway communication protocols

Currently, only direct serial and TCP communication are supported, but implementing further types is pretty easy. I'm open to pull requests.

NOTE: TCP connections are, as yet, untested. Please open an issue if you're experiencing difficulties.

Supported MQTT brokers

The MQTT client used is paho. It's one of the most widely-used MQTT clients for Python, so it should work on most brokers. If you're having problems with a certain type, please open an issue or send me a pull request with a fix.

Configuration

The configuration for the bridge is located in config.json.

Example configuration

To use the serial connection to the OTGW, use a config.json like the following:

{
    "otgw" : {
        "type": "serial",
        "device": "/dev/ttyUSB0",
        "baudrate": 9600
    },
    "mqtt" : {
        "client_id": "otgw",
        "host": "127.0.0.1",
        "port": 1883,
        "keepalive": 60,
        "bind_address": "",
        "username": null,
        "password": null,
        "qos": 0,
        "pub_topic_namespace": "otgw/value",
        "sub_topic_namespace": "otgw/set"
    }
}

To use a TCP connection, replace the OTGW section with this:

    "otgw" : {
        "type": "tcp",
        "host": "<OTGW HOSTNAME OR IP>",
        "port": 2323
    },

Installation

To install this script as a daemon, run the following commands (on a Debian-based distribution):

  1. Install dependencies:
    sudo apt install python3 python3-serial python3-paho-mqtt
  2. Create a new folder, for example:
    sudo mkdir -p /opt/otgw
    cd /opt/otgw
  3. Clone this repository into the current directory:
    sudo git clone https://github.com/kobbejager/otgw.git .
  4. Copy the config.json.example file to config.json
    sudo cp config.json.example config.json
  5. Change config.json with your favorite text editor
  6. Copy the service file to the systemd directory. If you used a different folder name than /opt/otgw you will need to change the WorkingDirectory in the file first.
    sudo cp ./otgw.service /etc/systemd/system/
  7. Enable the service so it starts up on boot:
    sudo systemctl daemon-reload
    sudo systemctl enable otgw.service
  8. Start up the service
    sudo systemctl start otgw.service
  9. View the log to see if everything works
    journalctl -u otgw.service -f

Topics

Publish topics

By default, the service publishes messages to the following MQTT topics:

  • otgw/value => The status of the service
  • otgw/value/master_slave_status
  • otgw/value/status/fault
  • otgw/value/status/ch_active
  • otgw/value/status/flame_on
  • otgw/value/status/dhw_active
  • otgw/value/status/cooling_active
  • otgw/value/status/ch2_active
  • otgw/value/status/diagnostic_indication
  • otgw/value/status/ch_enabled
  • otgw/value/status/dhw_enabled
  • otgw/value/status/cooling_enabled
  • otgw/value/status/otc_active
  • otgw/value/status/ch2_enable
  • otgw/value/control_setpoint
  • otgw/value/remote_override_setpoint
  • otgw/value/max_relative_modulation_level
  • otgw/value/room_setpoint
  • otgw/value/relative_modulation_level
  • otgw/value/ch_water_pressure
  • otgw/value/room_temperature
  • otgw/value/boiler_water_temperature
  • otgw/value/dhw_temperature
  • otgw/value/outside_temperature
  • otgw/value/return_water_temperature
  • otgw/value/dhw_setpoint
  • otgw/value/max_ch_water_setpoint
  • otgw/value/burner_starts
  • otgw/value/ch_pump_starts
  • otgw/value/dhw_pump_starts
  • otgw/value/dhw_burner_starts
  • otgw/value/burner_operation_hours
  • otgw/value/ch_pump_operation_hours
  • otgw/value/dhw_pump_valve_operation_hours
  • otgw/value/dhw_burner_operation_hours

If you've changed the pub_topic_namespace value in the configuration, replace otgw/value with your configured value. TODO: Add description of all topics

Subscription topics

By default, the service listens to messages from the following MQTT topics:

  • otgw/set/room_setpoint/temporary - TT - Float
  • otgw/set/room_setpoint/constant - TC - Float
  • otgw/set/outside_temperature - OT - Float
  • otgw/set/hot_water/enable - HW - Boolean
  • otgw/set/hot_water/temperature - SW - Float
  • otgw/set/central_heating/enable - CH - Boolean
  • otgw/set/central_heating/temperature - SH - Float
  • otgw/set/control_setpoint - CS - Float
  • otgw/set/max_modulation - MM - Integer 0-100
  • otgw/set/cmd (takes any otgw command e.g. TT=20)

TODO: Add description of all topics

About

Python OTGW MQTT bridge

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.8%
  • Dockerfile 1.2%
0