Skip to content
forked from zanac/pyHPSU

Python Script to read and send commands to a Rotex HPSU

Notifications You must be signed in to change notification settings

Spanni26/pyHPSU

 
 

Repository files navigation

Using pyHPSU may cause damage to the heating system. The use of pyHPSU is at your own risk. The creator can not be held responsible for damage.

You may risk a loss of warranty and support from the manufacturer!!!!

This software is not supported by the manufacturer!!!!

Welcome to pyHPSU

pyHPSU is a set of python scripts and other files to read and modify the values of the Rotex® HPSU (possibly) also identical heating pumps from daikin®).

It is based on the idea and the work of Vanni Brutto alias Zanac

It is expandable via plugins to send data to other systems and databases. At the momeent, Emoncms, fhem, homematic, influxdb, mqtt, mysql and openhab are supported.

It works with SocketCan OR the elm327 based serial-can interfaces.
The advantage of SocketCan: it can handle multiple instances or programs talking over the same can interface or you can query multiple values with one command. Message queuing is done by the kernel. For serial can interfaces (like the Elm327) you need a server which handles the messages. To do this, pyHPSUd.py is there. It handles multiple pyHPSU.py session via rabbitMQ.

Hardware setup

  1. Via Elm327 interface
  • Most cheap china replicas will not work because the "AT PP" command is not implemented. A purchase recommendation is as follows: https://www.totalcardiagnostics.com/elm327 or ahermann86 is using https://www.amazon.de/dp/B06XJ6GQZX/ref=cm_sw_em_r_mt_dp_U_OLP.CbG0Z7YKR
  • It is recommended to order a matching obd2 socket (16pol) to connect the can adapter
  • Connect the CAN-High cable pin 6, the CAN-Low cable pin 14 and CAN signal ground pin 5 to the hpsu mainboards "J13" connector. (Power on the CAN-Side is not needed)
  • look at your systems "dmesg" while connecting to get the device name
  1. SocketCan
  • connect the Pins from the HPSU mainboards "J13" connector to the pins of your can interface. Needed are canH, canL and ground.
  • for debian (and other systems) and the following to /etc/network/interfaces:
  auto can0  
  iface can0 inet manual  
    pre-up /sbin/ip link set $IFACE type can bitrate 20000 triple-sampling on  
    up /sbin/ifconfig $IFACE up  
    down /sbin/ifconfig $IFACE down

Software setup

pyHPSU only runs on unix/linux based systems.

  1. To run pyHPSU you need python3 and these python packages:
  • python-can==3.3.4
  • serial
  • pika
  • requests
  • mysql.connector (used by the db plugin)
  • urllib3 (used by the homematic plugin)
  • paho-mqtt (used by the mqtt plugin)
  • influxdb (used by the influxdb plugn)
  1. git clone https://github.com/Spanni26/pyHPSU
  2. cd pyHPSU
  3. chmod +x install.sh
  4. sh install.sh

Using pyHPSU

PyHPSU defaults

  • can-device: SocketCan (Driver canpi, for elm327 specify the driver with -d canelm327 and the line with e.g. -p /dev/ttyUSB )
  • OutputFormat: JSON (other formats or output devices can be specified with "-o", the usage via "pyHPSU.py -?")

To get a list of all available commands call:
root@rotex:# pyHPSU.py -h

To get a bit more information about a single command:
root@rotex:# pyHPSU.py -h -c <command>
e.g. root@rotex:# pyHPSU.py -h -c t_hs

To query a value (e.g. t_hs): root@rotex:# pyHPSU.py -c t_hs

The default setting is the output to the console in json format, so the output will look like this: [{'name': 't_hs', 'resp': '32.00', 'timestamp': 1544534667.414178}]

Output options ("-o <output>")

CSV

Output is send to console in CSV format (comma separated value)

DB

If a database should be used simply create a mysql DB with collation "utf8_bin", edit the pyhpsu.conf and select "DB" as output type Configure it in /etc/pyHPSU/pyhpsu.conf (look at the code of /usr/lib/python3/dist-packages/HPSU/plugins/db.py to find a template).

EMONCMS

Send the data to an emoncms instance (locally or the web version) Configure it in /etc/pyHPSU/pyhpsu.conf (look at the code of /usr/lib/python3/dist-packages/HPSU/plugins/emoncms.py to find a template).

FHEM

Send the data to a fhem instance. Atm only pushing the values via telnet to port 7072 is supported. Configure it in /etc/pyHPSU/pyhpsu.conf (look at the code of /usr/lib/python3/dist-packages/HPSU/plugins/fhem.py to find a template).

HOMEMATIC

Send the data to homematic. Therefore the xmlapi has to be installed on the ccu, a system variable has to be configured and the ise_id of this variable must be configured in the pyHPSU.conf (look ath the code of /usr/lib/python3/dist-packages/HPSU/plugins/fhem.py to find a template).

INFLUXDB

Send the data to the InfluxDB Time Series database. Configure it in /etc/pyHPSU/pyhpsu.conf (look at the code of /usr/lib/python3/dist-packages/HPSU/plugins/influxdb.py to find a template).

MQTT

Send the data to an MQTT broker. Configure it in /etc/pyHPSU/pyhpsu.conf (look at the code of /usr/lib/python3/dist-packages/HPSU/plugins/mqtt.py to find a template).

OPENHAB

Send the data to openHAB. Create an item for every command you want to use. You have to use a Prefix like Rotex_ for all pyHPSU related item names. So pyHPSU will push every value to a item named [Prefix][command]. For example, if you want to send commands mode and t_dhw1 to openHAB, create those items in you openHAB item config.

Number Rotex_mode      "Modus [MAP(heatpump_mode.map):%s]"
Number Rotex_t_dhw1    "Temperatur im Warmwasserspeicher [%.1f °C]"

For commands like mode, which a number represents a state, you can use openHABs mapping feature to map state numbers to a textual description.

Point pyHPSU to your openHAB system in /etc/pyHPSU/pyhpsu.conf file. Also use Auto Mode and configure your commands in [JOBS] section.

[OPENHAB]
HOST = hostname_or_ip
PORT = 8080
ITEMPREFIX = Rotex_

[JOBS]
mode = 30
t_dhw1 = 60

Modes

pyHPSU.py can be run un different modes.

  1. Standalone You can run the pyHPSU.py in standalone mode forom the command line.
    e.g. query the value of t_hs, output in CSV format, using an elm327 interface on port /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_-if00-port0
    root@rotex:# pyHPSU.py -c t_hs -d elm327 -p /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_-if00-port0 -o CSV
    e.g. ask the heating pump for an pending error, output in JSON format, using an SocketCan interface
    root@rotex:# pyHPSU.py -c error -o JSON -d canpi
    or simply (cause JSON and canpi are the defaults):
    root@rotex:# pyHPSU.py -c error

  2. Auto Mode The pyHPSU.py can be run in "auto mode". You can define values which should be querried in different periods. This is done at /etc/pyHPSU/pyhpsu.conf.
    At the "jobs" section add the value and the period (as shown by the examples) and addopt the section "PYHPSU" to your needs. Then, run the pyHPSU.py with the parameter "-a"
    e.g.
    root@rotex:# pyHPSU.py -a

  3. With Message Broker (only needed with serial intrerfaces like Elm327)
    A serial line can only be used by one process at a time. So, if you query more then one value at a time or you run multiple instances of pyHPSU.py you can run in errors.
    In this mode, every query from pyHPSU.py is sent to the pyHPSUD.py. This daemon deals with the message broker "rabbitmq" which sends one query at a time and sorts the answers to the correct sending process.
    For that, install the message broker "rabbitmq". You also have to configure the config file /etc/pyHPSU/pyhpsu.conf at section "PYHPSUD".
    Here, specify the driver, language and serial port to use.
    The pyHPSUD.py is started via systemd:
    root@rotex:# systemctl enable hpsud.service
    root@rotex:# systemctl start hpsud.service

Now, you can query multiple values or run multiple pyHPSU.py processes. Simply set as driver HPSUD ("CANTCP") via commandline or the config file (PYHPSU section) i.e. root@rotex:# pyHPSU.py -d HPSUD -c t_dhw_setpoint1

About

Python Script to read and send commands to a Rotex HPSU

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 98.3%
  • Shell 1.7%