1
0
mirror of https://github.com/pommi/python-itho-wpu.git synced 2024-12-21 18:43:27 +01:00
Commit Graph

51 Commits

Author SHA1 Message Date
7048014a22 feat: add support for reading counters 2023-09-11 20:07:59 +02:00
f0c350971f chore(itho-wpu): rename wpu.get -> wpu.call 2023-09-11 20:07:59 +02:00
a11df838f8 feat: add support for writing manual operations
Initiating and finishing a manual operation works a bit strange. First
of all the Maximum Manual Operation Time is controlled by a setting
(--id 4) and defaults to 0 (infinite). And instead of waiting for the
timer to expire (which you have to do when its set to 0) you can finish
a manual operation by passing "--no-check".

Note: For some reason no response is given when a manual operation is
written to. That's why execute_action() returns succesfully (with None)
when its executing the "setmanual" action and the response queue size is 0.
2023-09-11 20:07:59 +02:00
63f06400ef feat: add support for reading manual operations 2023-07-21 16:34:12 +02:00
381dd4c6ec feat(itho-wpu): setsetting support
With action "setsetting" settings of an Itho WPU can be modified.
2023-07-19 16:31:49 +02:00
1ffd5a72d7 fix(itho_i2c): make loglevel in itho_i2c module adjustable 2023-07-19 15:35:04 +02:00
7a1140e26c feat(itho-wpu): getsettings support
A loop around getsetting based on the settings available in the
database to retrieve all settings from the WPU.

Example usage:
> ./itho-wpu.py --action getsettings
> 0. Niet Gebruikt: 0 (min: 0, max: 65535, step: 1)
> 1. Hardware Configuratie: 70 (min: 0, max: 65535, step: 1)
> 2. Jaar Inbedrijfstelling: 2010 (min: 2004, max: 2099, step: 1)
2023-07-19 15:35:04 +02:00
d28acae756 feat(itho-wpu): getsetting support
Action "getsetting" retrieves the value of a setting byi the provided id.

Example usage:
> ./itho-wpu.py --action getsetting --settingid 1
> 1. Hardware Configuratie: 70 (min: 0, max: 65535, step: 1)
> ./itho-wpu.py --action getsetting --settingid 2
> 2. Jaar Inbedrijfstelling: 2010 (min: 2004, max: 2099, step: 1)
2023-07-19 15:35:04 +02:00
620cdaf880 refactor: put datatype formatting in a separate function 2023-07-19 14:56:41 +02:00
a1f8328b50 feat: log the hex request in debug mode 2023-06-05 21:33:45 +02:00
8bde04ba41 fix(readme): suppress direnv loading output in cron
By default direnv outputs this while executing:
```
direnv: loading ~/python-itho-wpu/.envrc
```

In a cronjob this results in emails, or when no MTA is configured:
```
CRON[1095]: (CRON) info (No MTA installed, discarding output)
```
2022-12-25 14:02:55 +01:00
8f02e2b833 fix(readme): install odbcinst1debian2
odbcinst1debian2 is a dependency of odbc-mdbtools.
2022-12-25 13:55:04 +01:00
c41b700f13 feat(itho-wpu): support for all datatypes supported by the service tool
* 0x0: integer (1 byte)
* 0x1: 1 decimal float (1 byte)
* 0x2: 2 decimal float (1 byte)
* 0xc: integer (1 byte)
* 0xf: integer/2 (1 byte)
* 0x10: 0 decimal unsigned integer (2 bytes)
* 0x11: 1 decimal unsigned float (2 bytes)
* 0x12: 2 decimal unsigned float (2 bytes)
* 0x13: 3 decimal unsigned float (2 bytes)
* 0x14: 4 decimal unsigned float (2 bytes)
* 0x20: 0 decimal unsigned integer (4 bytes)
* 0x21: 1 decimal unsigned float (4 bytes)
* 0x22: 2 decimal unsigned float (4 bytes)
* 0x23: 3 decimal unsigned float (4 bytes)
* 0x24: 4 decimal unsigned float (4 bytes)
* 0x25: 5 decimal unsigned float (4 bytes)
* 0x5b: unsigned integer (2 bytes)
* 0x6c: integer (max 1) (1 byte)
* 0x80: 0 decimal signed integer (1 byte)
* 0x81: 1 decimal signed float (1 byte)
* 0x82: 2 decimal signed float (1 byte)
* 0x8f: 3 decimal signed float (1 byte)
* 0x90: 0 decimal signed integer (2 bytes)
* 0x91: 1 decimal signed float (2 bytes)
* 0x92: 2 decimal signed float (2 bytes)
* 0xa0: 0 decimal signed integer (4 bytes)
* 0xa1: 1 decimal signed float (4 bytes)
* 0xa2: 2 decimal signed float (4 bytes)
* 0xa3: 3 decimal signed float (4 bytes)
* 0xa4: 4 decimal signed float (4 bytes)
* 0xa5: 5 decimal signed float (4 bytes)
2021-06-10 14:14:46 +02:00
370209603b fix(itho-wpu): 0x90 is a 2 byte signed decimal 2021-06-10 13:19:54 +02:00
751182b70d style: apply flake8 and black formatting
To check for errors:
$ pre-commit run --all-files

To install as pre-commit hook:
$ pre-commit install
2021-05-30 14:52:24 +02:00
8c7d0ed947 docs(readme): save par file from Service Tool as HeatPump.par
mdbtools 0.9.3-1 is not able to handle filenames with special characters like "$".
2021-05-30 13:52:21 +02:00
153da73b08 docs(readme): update mdbtools to 0.9.3-1
mdbtools 0.9.3-1 from Debian Unstable also seems to work.
2021-05-30 13:46:19 +02:00
b936311e59 refactor: put all export related stuff in itho_export.py 2021-04-08 14:19:37 +02:00
7f4cdc8682 refactor: put all i2c related stuff in itho_i2c.py 2021-04-08 13:58:52 +02:00
cb3cde86be docs(readme): add grafana dashboard and demo 2021-03-25 14:56:53 +01:00
60c4a794a8 feat(itho-wpu): getdatalog: show name identifier in output
This shows the name identifier for each measurement. This identifier is
for example used to store measurements in InfluxDB.
2021-03-25 14:14:27 +01:00
236d5c34fc feat(itho-wpu): add timestamp argument to make it optional
By default don't output timestamps for each line. Provide command line
argument --timestamp to enable it again.
2021-03-25 14:13:21 +01:00
57954bafb4 docs(readme): installation and execution instructions 2021-03-17 21:19:14 +01:00
83acd955ba feat(gitignore): ignore .envrc, pycache, heatpump.sqlite 2021-03-14 13:43:23 +01:00
96f91cb9d3 feat(itho-wpu): get datalog structure from the database
Instead of hardcoding the datalog structure for listversion 11 (my WPU
version), get the datalog structure from the database and match that
against the result from the getdatatype call.

This way all WPU versions that are in the database are automatically
supported.
2021-03-14 13:41:46 +01:00
00f098f4e1 fix(itho-wpu): 0x12 is a 2 byte unsigned decimal 2021-03-07 14:59:59 +01:00
1f8eca43f6 feat(itho-wpu): populate IthoWPU object with nodeid, datatype
These are required to look up information in the database related to
your WPU version.
2021-03-07 14:59:59 +01:00
ff149eba6a feat(itho-wpu): cache results for getnodeid, getserial, getdatatype in a json file
The results for these calls are static. If we cache them we don't have
to retrieve it from the WPU every time we need it.

To ignore the cache (for reading), provide the --no-cache argument.
2021-03-07 14:59:59 +01:00
0b4b9a3d79 feat(itho-wpu): move itho interaction to an IthoWPU class
To be able to easily execute multiple actions.
2021-02-12 17:07:43 +01:00
8b34069fc6 feat(convert-itho-db): convert an itho servicetool database to sqlite
The SQLite database (a subset of the Itho database) can be used to
dynamically interact with an Itho WPU based on the WPU version.

> usage: convert-itho-db.py [-h] --itho-db [ITHO_DB] [--sqlite-db [SQLITE_DB]]
>                           [--force]
>
> Convert Itho Servicetool database to SQLite
>
> optional arguments:
>   -h, --help            show this help message and exit
>   --itho-db [ITHO_DB]   Itho Database file (default: None)
>   --sqlite-db [SQLITE_DB]
>                         Itho Database file (default: heatpump.sqlite)
>   --force               Force overwrite SQLite database (default: False)
2021-01-02 15:53:47 +01:00
d537ab80a3 feat(requirements.txt): python dependencies 2021-01-02 15:30:33 +01:00
ecc8bd123b Merge pull request #3 from WouterJN/patch-1
Update itho-wpu.py
2020-12-29 21:27:59 +01:00
WouterJN
ce846efb62 Update itho-wpu.py
Resolving issue with datatype 0xc (1 byte integer)
2020-12-27 22:57:22 +01:00
2a25e8148b feat(itho-wpu): use (hardcoded) datatype from getdatatype in datalog
Action "getdatatype" returns a list of bytes representing the datatype
for each field in action "getdatalog". This is a subset of these
datatypes:

* 0x0: integer (1 byte)
* 0xc: integer (1 byte)
* 0x10: unsigned integer (2 bytes)
* 0x92: 2 decimal signed float (2 bytes)
2020-12-03 14:48:50 +01:00
d40b0d94ff feat(itho-wpu): add manufacturer naming 2020-11-21 15:08:10 +01:00
273a22a4c0 refactor(itho-wpu): check messageclass in a central function 2020-11-16 14:04:54 +01:00
1a57a8bd9b feat(itho-wpu): implement getserial action 2020-11-15 15:26:25 +01:00
b0ea3a9473 refactor(itho-wpu): compose request + calculate checksum on the fly
Messages have 6 header bytes, data bytes and 1 checksum byte.

The 6 header bytes are:
1: i2c destination address (0x82)
2: i2c reply address (0x80)
3,4: message class
5: message type (0x04 = request)
6: data length (0x00 in case of a request)
2020-11-15 15:26:18 +01:00
58f35d988e feat(itho-wpu): implement getnodeid action 2020-11-15 15:18:12 +01:00
11ae0978b3 refactor(itho-wpu): check MessageType + move MessageClass check
MessageType 4th byte (5th if you include 0x80) is:
- 0x01: response
- 0x04: request
2020-11-14 15:31:37 +01:00
152b6021cf feat(itho-wpu): check message length
The 5th byte (6th if you include 0x80) contains the message length. To
double check if the message is correct we can check this against the
actual message length.
2020-11-14 15:10:59 +01:00
c43de957e9 feat(itho-wpu): export to influxdb support
Export getdatalog measurements to InfluxDB by giving the
'--export-to-influxdb' argument. Additionally configure the InfluxDB
credentials via environment variables:
- INFLUXDB_HOST (default: localhost)
- INFLUXDB_PORT (default: 8086)
- INFLUXDB_USERNAME (default: root)
- INFLUXDB_PASSWORD (default: root)
- INFLUXDB_DATABASE
2020-11-08 15:08:46 +01:00
c867203913 feat(itho-wpu): process getdatalog 2020-11-08 15:08:46 +01:00
d00e948208 feat(itho-wpu): rm slave thread + pass result to I2CMaster via a queue + add retry mechanism
Remove the slave thread, set_callback already spawns a thread.

I2CSlave.callback() now puts the result (if valid) in a queue. This item
can be picked up by I2CMaster for further processing.

I2CMaster will wait 0.21s for a result in the queue. 0.21s, because I
always see a response in < 0.2s. If there is no result, it will send the
request again (max 20 retries). This is because I don't get reliable
responses (via pigpiod?). In an earlier commit I mentioned to configure
pigpiod with -s 2 (sample rate 2 microseconds).  This doesn't seem to be
true. For example -s 10 gives the same reliability (and less CPU usage
by pigpiod).
2020-11-08 15:08:46 +01:00
e3bc670050 refactor(itho-wpu): rm wait type
The wait type is unreliable. No reason to keep maintaining this.
2020-11-05 13:42:21 +01:00
c7b5171a66 feat(itho-wpu): add checksum validation for received messages 2020-11-05 13:41:47 +01:00
f989b61789 feat(itho-wpu): cli arguments to run master/slave only + set slave timeout
--master-only allows to only run the I2C master functionality.
--slave-only allows to only run the I2C slave functionality.

The I2C slave functionality via the "set_callback" mechanism (--type
callback) just executes the pigpio "event_callback()" function and waits
for 2 seconds for a response. The amount of seconds can now be
configured via --slave-timeout.
2020-10-25 13:54:43 +01:00
ff3c705608 feat(itho-wpu): option to slave via event_callback()
Argument "--type [callback,wait]" is added to be able to switch between
"wait_for_event()" (previous functionality) and "event_callback()" in
the I2C slave functionality.

In a thread set_callback() executes event_callback() and just (very
dirty) sleeps 2 seconds to get a response or else cancels the event and
stops pigpio.

To get the most reliable output pigpiod is started with -s 2 (sample
rate 2 microseconds). Still most of the time too few bytes are received
on the "getdatalog" action (153 bytes expected).
2020-10-22 14:39:04 +02:00
15c6103820 feat(itho-wpu): basic slave functionality
This uses the pigpio library as I'm not quite sure yet how to read this
data directly from /dev/i2c-1, without polling and high CPU usage.
2020-10-22 14:38:43 +02:00
91913c4fe7 feat(itho-wpu): initial i2c master functionality
Writing directly to the /dev/i2c-1 device.

Support for 4 actions:
- getregelaar
- getserial
- getdatatype
- getdatalog
2020-10-17 18:05:56 +02:00