1
0
mirror of https://github.com/pommi/python-itho-wpu.git synced 2024-12-21 18:43:27 +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 47ba1225c8
commit 482e6c8c60
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) 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 # Exporting measurements
## InfluxDB ## InfluxDB

View File

@ -34,7 +34,7 @@ def parse_args():
"--action", "--action",
nargs="?", nargs="?",
required=True, required=True,
choices=actions.keys(), choices=list(actions.keys()) + ["getsettings"],
help="Execute an action", help="Execute an action",
) )
parser.add_argument( parser.add_argument(
@ -157,6 +157,20 @@ class IthoWPU:
return datalog return datalog
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): def get_setting_by_id(self, settingid):
listversion = self.get_listversion_from_nodeid() listversion = self.get_listversion_from_nodeid()
parameterlist_version = self.heatpump_db.execute( parameterlist_version = self.heatpump_db.execute(
@ -324,6 +338,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): def format_datatype(name, m, dt):
num = None num = None
if type(dt) is str: if type(dt) is str:
@ -399,6 +421,11 @@ def main():
return return
wpu = IthoWPU(args.master_only, args.slave_only, args.slave_timeout, args.no_cache) 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) response = wpu.get(args.action, args.settingid)
if response is not None: if response is not None:
process_response(args.action, response, args, wpu) process_response(args.action, response, args, wpu)