Giter VIP home page Giter VIP logo

heat-pump-telemetry-exporter's Introduction

Introduction

This Python based project allows you to monitor your Alpha Innotec (or any other heat pump that supports a Luxtronix control panel) and get information such as water and room temperatures, pump status etc. into a dashboard using Prometheus and Grafana.

Setup Diagram

While the intention of this project is run this on a Raspberry Pi, any computer that can run Python will work.

This is still a work in progress. Not all metrics are fully supported and tested and this solution only reads data from the heat pump andis not able to control the heatpump's features.

Setup & Configuration

This documentation assumes that you are already familiar with setting up Prometheus and Grafana and that you know how to scrape metrics and present data in dashbaords.

It is also recommended that you understand how to setup services in systemd if want thes tools to start automatically on your Raspberry Pi.

Edit the config.py file to configure the port you wish to export metrics on and the IP address of your heat pump.

serverHost = "0.0.0.0"
serverPort = 8888

heatpumpHost = "192.168.2.77"
heatPumpPort = "8214"

Use the metrics dictionary to add new metrics that you'd like to add or adapt your configuration to your heat pump's language if you prefer Dutch, German etc.

Don't forget to install the required python dependencies. This project attempts to use as few dependencies as possible and should only require the requests and websocket-client packages to be installed via pip.

Start the exporter by running main.py.

Metrics

Using curl http://localhost:8888 you can verify which metrics are being read from your heat pump. Here's a sample below:

# HELP heat_pump_ambient_temperature The current ambient temperature in degrees celsius. Generally this is the outside temperature.
# TYPE heat_pump_ambient_temperature gauge
heat_pump_ambient_temperature 19.6
# HELP heat_pump_current_room_temperature The current room temperature in degrees celsius.
# TYPE heat_pump_current_room_temperature gauge
heat_pump_current_room_temperature 22.9
# HELP heat_pump_actual_service_water_temperature The actual service water temperature in degrees celsius. The current temperature of water supplying hot water taps. 
# TYPE heat_pump_actual_service_water_temperature gauge
heat_pump_actual_service_water_temperature 54.1
# HELP heat_pump_target_service_water_temperature The target service water temperature in degrees celsius.
# TYPE heat_pump_target_service_water_temperature gauge
heat_pump_target_service_water_temperature 54.0
# HELP heat_pump_flow_temperature The flow temperature in degrees celsius. The flow temperature refers to the temperature of the water in the supply (flow) pipe in a heating system or separate part of a heating system.
# TYPE heat_pump_flow_temperature gauge
heat_pump_flow_temperature 25.2
# HELP heat_pump_return_temperature The return temperature in degrees celsius. The return temperature is the temperature of the water in the pipe system after heat has been released into the building. The difference between inlet temperature and return temperature of the water occurs during transport through the heating system.
# TYPE heat_pump_return_temperature gauge
heat_pump_return_temperature 29.1
# HELP heat_pump_target_return_temperature The target return temperature in degrees celsius.
# TYPE heat_pump_target_return_temperature gauge
heat_pump_target_return_temperature 15.0
# HELP heat_pump_hot_gas_temperature The hot gas temperature in degrees celsius.
# TYPE heat_pump_hot_gas_temperature gauge
heat_pump_hot_gas_temperature 29.3
# HELP heat_pump_input_heat_source_temperature The input heat source temperature in degrees celsius.
# TYPE heat_pump_input_heat_source_temperature gauge
heat_pump_input_heat_source_temperature 20.5
# HELP heat_pump_intake_compressor_temperature The intake compressor temperature in degrees celsius.
# TYPE heat_pump_intake_compressor_temperature gauge
heat_pump_intake_compressor_temperature 39.2
# HELP heat_pump_intake_vapor_temperature The intake vapor temperature in degrees celsius.
# TYPE heat_pump_intake_vapor_temperature gauge
heat_pump_intake_vapor_temperature 18.3
# HELP heat_pump_2nd_heat_generator_1_status Second heat generator 1 status (e.g. electric heating element) in the storage tank (0=Off 1=On).
# TYPE heat_pump_2nd_heat_generator_1_status gauge
heat_pump_2nd_heat_generator_1_status 0

Running the Heat-pump Exporter as a service

It is recommended that you configure the exporter as a systemd service. This tutorial is good guide but if you've setup Prometheus or Grafana before you've done this before.

Here's an example of what a heat-pump-exporter.service file added to your Pi's /etc/systemd/system/ directory can look like if you installed the heat pump telemetru exporter to /opt/heat-pump-telemetry-exporter.

[Unit]
Description=Heat Pump Telemetry Exporter
Documentation=https://github.com/gerarddejong/heat-pump-telemetry-exporter
After=network-online.target

[Service]
User=pi
Restart=on-failure

ExecStart=python3 /opt/heat-pump-telemetry-exporter/main.py
WorkingDirectory=/opt/heat-pump-telemetry-exporter/

[Install]
WantedBy=multi-user.target

Integration with Prometheus & Grafana

Once you've got metrics comming in via the exporter you'll need to update your prometheus.yml configuration to scrape data into the time series database. Here's an example of what to add under the scrape_configs: section:

- job_name: heat-pump
  honor_timestamps: true
  scrape_interval: 60s
  scrape_timeout: 60s
  metrics_path: /metrics
  scheme: http
  follow_redirects: true
  enable_http2: true
  static_configs:
  - targets:
    - localhost:8888

Remember not to set the scrape interval to often. Other implementations can scrape data every 10 seconds or less this is has crashed the Luxtronic control panel 2x in my experience and appears more stable on an interval of 60 seconds.

You can import the provided Heat Pump-Grafana-Dashboard.json dashboard into Grafana version 10 or later.

Adding Additional Metrics

If you would like to add additional metrics, add them to the config.py file's metrics dictionary and be sure to use the exact same names used in the Web UI's WebSocket implementation. The dictionary holds the title of each menu section as the key to each metric's group and the a specific metric can be chosen to be made availble for export to Prometheus. name is the name is the metric is called in the ebSocket implementation the variable key can be used to change what the metric is called when imported to Prometheus.

"Temperatures" : [
        {
            "name": "Amb. temp.",
            "help": "The current ambient temperature in degrees celsius. Generally this is the outside temperature.",
            "type": "gauge",
            "variable" : "heat_pump_ambient_temperature"
        }
]

Note that f you wish to add your own metrics and they use unknown units that such data will require some conversion and parsing to prevent errors.

Localisation & Language Support

If you are running your heat pump contol panned in a differnt language, expect to need to update the config.py file with the correct translation for your language. If you do any translations please consider submitting them as an update to this project via a pull request. Something like config_de.py or config_nl.py will be appreciated.

Security Considerations

It is recommended that you never make your heat pump direclty accessible to the internet. One method would be put a Raspberry Pi in between the heat pump and the rest of your network in order to isolate it by connecting the heat pump to the ethernet jack of the Pi and then connecting the Pi to you Wifi via the Pi's built in Wifi or an USB dongle.

This can be further secured with a firewall such as UFW and serving metrics via https.

heat-pump-telemetry-exporter's People

Stargazers

 avatar  avatar Tomi P. Hakala avatar

Watchers

 avatar

Forkers

romanwoessner

heat-pump-telemetry-exporter's Issues

Connection to remote host was lost

When spinning up the program with python3 main.py after editing the config.py and doing a curl request on localhost:8888/metrics I get:

Exception occurred during processing of request from ('127.0.0.1', 57959)
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/socketserver.py", line 317, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/opt/homebrew/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/socketserver.py", line 348, in process_request
    self.finish_request(request, client_address)
  File "/opt/homebrew/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/socketserver.py", line 361, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/opt/homebrew/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/socketserver.py", line 755, in __init__
    self.handle()
  File "/opt/homebrew/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/server.py", line 436, in handle
    self.handle_one_request()
  File "/opt/homebrew/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/server.py", line 424, in handle_one_request
    method()
  File "/private/tmp/heat-pump-telemetry-exporter/main.py", line 77, in do_GET
    metricsResponseString = HeatPumpTelemetry.getMetrics(HeatPumpTelemetry)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/private/tmp/heat-pump-telemetry-exporter/main.py", line 31, in getMetrics
    contentResponseString = webSocketConnection.recv()
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/websocket/_core.py", line 362, in recv
    opcode, data = self.recv_data()
                   ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/websocket/_core.py", line 385, in recv_data
    opcode, frame = self.recv_data_frame(control_frame)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/websocket/_core.py", line 406, in recv_data_frame
    frame = self.recv_frame()
            ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/websocket/_core.py", line 445, in recv_frame
    return self.frame_buffer.recv_frame()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/websocket/_abnf.py", line 338, in recv_frame
    self.recv_header()
  File "/opt/homebrew/lib/python3.11/site-packages/websocket/_abnf.py", line 294, in recv_header
    header = self.recv_strict(2)
             ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/websocket/_abnf.py", line 373, in recv_strict
    bytes_ = self.recv(min(16384, shortage))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/websocket/_core.py", line 529, in _recv
    return recv(self.sock, bufsize)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/websocket/_socket.py", line 122, in recv
    raise WebSocketConnectionClosedException(
websocket._exceptions.WebSocketConnectionClosedException: Connection to remote host was lost.
----------------------------------------

I've verified that the IP of the pump is correct and I manually applied the patch in PR #1.

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.