1
0
mirror of https://github.com/pommi/python-itho-wpu.git synced 2024-10-31 10:42:17 +01:00

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)
This commit is contained in:
Pim van den Berg 2023-07-11 16:01:42 +02:00
parent d28acae756
commit 7a1140e26c
2 changed files with 44 additions and 1 deletions

View File

@ -105,6 +105,22 @@ See the [pislave](https://github.com/ootjersb/pislave#wiring) project
1. Hardware Configuratie: 70 (min: 0, max: 65535, step: 1)
```
* Retrieve all settings from the WPU
```
# ./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)
3. Datum Van Inbedrijfstelling: 101 (min: 0, max: 3112, step: 1)
4. Max Handbedieningstijd (min): 0 (min: 0, max: 600, step: 1)
5. Vorsttemp (°C): 2.0 (min: -10.0, max: 10.0, step: 0.1)
6. Offset Voor Vorst Temp (K): 2.0 (min: 0.0, max: 10.0, step: 0.1)
7. Differentie Van Vorst Om Elektrisch Element Te Starten (K): 1.5 (min: 0.0, max: 10.0, step: 0.1)
8. Fout Reset Tijd (min): 120 (min: 1, max: 1440, step: 1)
9. Loginterval Tijd (sec): 5 (min: 1, max: 300, step: 1)
...
```
# Exporting measurements
## InfluxDB

View File

@ -34,7 +34,7 @@ def parse_args():
"--action",
nargs="?",
required=True,
choices=actions.keys(),
choices=list(actions.keys()) + ["getsettings"],
help="Execute an action",
)
parser.add_argument(
@ -157,6 +157,20 @@ class IthoWPU:
return datalog
return datalog
def get_settings(self):
listversion = self.get_listversion_from_nodeid()
parameterlist_version = self.heatpump_db.execute(
f"SELECT parameterlist FROM versiebeheer WHERE version = {listversion}"
)[0]["parameterlist"]
if parameterlist_version is None or not type(parameterlist_version) == int:
logger.error(f"Parameterlist not found in database for version {listversion}")
return None
settings = self.heatpump_db.execute(
"SELECT id, name, min, max, def, title, description, unit "
+ f"FROM parameterlijst_v{parameterlist_version}"
)
return settings
def get_setting_by_id(self, settingid):
listversion = self.get_listversion_from_nodeid()
parameterlist_version = self.heatpump_db.execute(
@ -339,6 +353,14 @@ def process_setting(response, wpu):
)
def process_settings(wpu, args):
settings = wpu.get_settings()
for setting in settings:
response = wpu.get("getsetting", int(setting["id"]))
if response is not None:
process_response("getsetting", response, args, wpu)
def format_datatype(name, m, dt):
"""
Transform a list of bytes to a readable number based on the datatype.
@ -423,6 +445,11 @@ def main():
return
wpu = IthoWPU(args.master_only, args.slave_only, args.slave_timeout, args.no_cache)
if args.action == "getsettings":
process_settings(wpu, args)
return
response = wpu.get(args.action, args.settingid)
if response is not None:
process_response(args.action, response, args, wpu)