Add support for ventilation volume.

This commit is contained in:
Laur Ivan 2023-07-03 23:49:45 +02:00
parent 3b423e012b
commit c4ba4e027a
7 changed files with 73 additions and 26 deletions

1
.env
View File

@ -1,5 +1,6 @@
KNX_GATEWAY_IP=10.0.0.36 KNX_GATEWAY_IP=10.0.0.36
KNX_TOPOLOGY=export-addresses.csv KNX_TOPOLOGY=export-addresses.csv
LOG_ONLY=1
INFLUX_BUCKET=my_bucket INFLUX_BUCKET=my_bucket
INFLUX_ORG=example.com INFLUX_ORG=example.com

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
venv/ .venv/
requirements/ requirements/
__py*/ __py*/
.env .env

View File

@ -19,7 +19,9 @@ pip install --no-cache-dir -r .requirements.txt
You need to configure the following environment variables: You need to configure the following environment variables:
- `KNX_GATEWAY_IP` is the address of the gateway/router. Default value is *10.0.0.36* - `KNX_GATEWAY_IP` is the address of the gateway/router. Default value is *10.0.0.36*
- `KNX_TOPOLOGY` is the CSV export of the group adresses. It's used to map the monitored data with types and store the proper values. It defaults to *export-addresses.csv*. PLease see below how to export the right format. - `KNX_TOPOLOGY` is the CSV export of the group adresses. It's used to map the monitored data with types and store the proper values. It defaults to *export-addresses.csv*. Please see below how to export the right format.
- `LOG_ONLY` only logs the collected information, doesn't push to InfluxDB. It defaults to *1*
- `INFLUX_BUCKET` - the bucket to store the data. It defaults to *my_bucket* - `INFLUX_BUCKET` - the bucket to store the data. It defaults to *my_bucket*
- `INFLUX_ORG` - the organisation (defined when you initialise the bucket). Defaults to *example.com* - `INFLUX_ORG` - the organisation (defined when you initialise the bucket). Defaults to *example.com*

4
db.py
View File

@ -17,9 +17,13 @@ write_api = client.write_api(write_options=SYNCHRONOUS)
def publish_measurement(value): def publish_measurement(value):
# Only push to Influx if not logging
if (os.environ.get('LOG_ONLY', "0") != "1"):
try: try:
p = influxdb_client.Point(f'KNX-{value["type"]}').tag("name", f'{value["name"]}').tag("destination", f'{value["destination"]}').tag("description", f'{value["description"]}').field("value", value["value"]) p = influxdb_client.Point(f'KNX-{value["type"]}').tag("name", f'{value["name"]}').tag("destination", f'{value["destination"]}').tag("description", f'{value["description"]}').field("value", value["value"])
write_api.write(bucket=bucket, org=org, record=p) write_api.write(bucket=bucket, org=org, record=p)
except Exception as e: except Exception as e:
print(f"Could not send value {value} to {url}") print(f"Could not send value {value} to {url}")
print(e) print(e)
else:
print(f"debug: {value}")

View File

@ -1,5 +1,41 @@
"Group name";"Address";"Central";"Unfiltered";"Description";"DatapointType";"Security" "Group name";"Address";"Central";"Unfiltered";"Description";"DatapointType";"Security"
"Cellar - HVAC";"0/-/-";"";"";"";"";"Auto" "Global - Building Based";"0/-/-";"";"";"";"";"Auto"
"Timers";"0/0/-";"";"";"";"";"Auto"
"Current Time";"0/0/1";"";"";"";"DPST-10-1";"Auto"
"Current date";"0/0/2";"";"";"";"DPST-11-1";"Auto"
"Ventilation";"0/1/-";"";"";"";"";"Auto"
"Ventilation SW";"0/1/0";"";"";"";"DPT-5";"Auto"
"Ventilation FB";"0/1/1";"";"";"";"DPT-5";"Auto"
"External setpoint SW";"0/1/2";"";"";"";"";"Auto"
"External setpoint FB";"0/1/3";"";"";"";"";"Auto"
"Boost SW";"0/1/4";"";"";"";"DPT-1";"Auto"
"Boost FB";"0/1/5";"";"";"";"";"Auto"
"Boost time SW";"0/1/6";"";"";"";"DPT-7";"Auto"
"Boost time FB";"0/1/7";"";"";"";"";"Auto"
"Temperature profile SW";"0/1/8";"";"";"";"DPT-5";"Auto"
"Temperature profile FB";"0/1/9";"";"";"";"DPT-5";"Auto"
"Temperature profile mode SW";"0/1/10";"";"";"";"DPT-5";"Auto"
"Temperature profile mode FB";"0/1/11";"";"";"";"DPT-5";"Auto"
"Away function SW";"0/1/12";"";"";"";"DPT-1";"Auto"
"Away function FB";"0/1/13";"";"";"";"";"Auto"
"Ventilator preset 0 (Away) SW";"0/1/14";"";"";"";"DPT-1";"Auto"
"Ventilator preset 1 SW";"0/1/15";"";"";"";"DPT-1";"Auto"
"Ventilator preset 2 SW";"0/1/16";"";"";"";"DPT-1";"Auto"
"Ventilator preset 3 SW";"0/1/17";"";"";"";"DPT-1";"Auto"
"Ventilator preset 0 (Away) FB";"0/1/18";"";"";"";"DPT-1";"Auto"
"Ventilator preset 1 FB";"0/1/19";"";"";"";"DPT-1";"Auto"
"Ventilator preset 2 FB";"0/1/20";"";"";"";"DPT-1";"Auto"
"Ventilator preset 3 FB";"0/1/21";"";"";"";"DPT-1";"Auto"
"Auto mode SW";"0/1/22";"";"";"";"DPT-1";"Auto"
"Auto mode FB";"0/1/23";"";"";"";"DPT-1";"Auto"
"ComfoCool SW";"0/1/24";"";"";"";"DPT-1";"Auto"
"ComfoCool FB";"0/1/25";"";"";"";"DPT-1";"Auto"
"Ventilator preset SW";"0/1/26";"";"";"";"DPT-5";"Auto"
"Ventilator preset FB";"0/1/27";"";"";"";"DPT-5";"Auto"
"Temperature - Supply FB";"0/1/28";"";"";"";"DPT-9";"Auto"
"Temperature - Exhaust FB";"0/1/29";"";"";"";"DPT-9";"Auto"
"Temperature - Extract FB";"0/1/30";"";"";"";"DPT-9";"Auto"
"Airflow FB";"0/1/31";"";"";"";"DPT-13";"Auto"
"Media - HVAC";"0/3/-";"";"";"";"";"Auto" "Media - HVAC";"0/3/-";"";"";"";"";"Auto"
"Valve1-1 Media [CTEMP 1.3.10]";"0/3/6";"";"";"Wellness Lounge H";"DPST-9-1";"Auto" "Valve1-1 Media [CTEMP 1.3.10]";"0/3/6";"";"";"Wellness Lounge H";"DPST-9-1";"Auto"
"Valve1-1 Media [SETPOINT TEMP]";"0/3/7";"";"";"Wellness Lounge H";"DPST-9-1";"Auto" "Valve1-1 Media [SETPOINT TEMP]";"0/3/7";"";"";"Wellness Lounge H";"DPST-9-1";"Auto"
@ -11,12 +47,6 @@
"Valve1-2 Lounge [CMD]";"0/5/4";"";"";"Wellness HVAC - Lounge";"DPST-5-1";"Auto" "Valve1-2 Lounge [CMD]";"0/5/4";"";"";"Wellness HVAC - Lounge";"DPST-5-1";"Auto"
"Valve1-2 Lounge [OP]";"0/5/5";"";"";"Wellness HVAC - Lounge";"DPST-20-102";"Auto" "Valve1-2 Lounge [OP]";"0/5/5";"";"";"Wellness HVAC - Lounge";"DPST-20-102";"Auto"
"Ground floor";"2/-/-";"";"";"";"";"Auto" "Ground floor";"2/-/-";"";"";"";"";"Auto"
"Dining";"2/3/-";"";"";"";"";"Auto"
"Lights1-1[78] Dining all lights [SW]";"2/3/4";"";"";"Dining room All";"DPST-1-1";"Auto"
"Lights1-1[78] Dining all lights [FB]";"2/3/5";"";"";"Dining room All";"DPST-1-1";"Auto"
"Living";"2/6/-";"";"";"";"";"Auto"
"Lights1-[16,18,20,21] Living all [SW]";"2/6/8";"";"";"Living room All";"DPST-1-1";"Auto"
"Lights1-[16,18,20,21] Living all [FB]";"2/6/9";"";"";"Living room All";"DPST-1-1";"Auto"
"First floor - HVAC";"3/-/-";"";"";"";"";"Auto" "First floor - HVAC";"3/-/-";"";"";"";"";"Auto"
"Master bed - HVAC";"3/1/-";"";"";"";"";"Auto" "Master bed - HVAC";"3/1/-";"";"";"";"";"Auto"
"Valve2-2 Master bed [CTEMP 2.2.1]";"3/1/14";"";"";"Master HVAC";"DPST-9-1";"Auto" "Valve2-2 Master bed [CTEMP 2.2.1]";"3/1/14";"";"";"Master HVAC";"DPST-9-1";"Auto"
@ -89,9 +119,8 @@ Sender done via NodeRed.";"DPST-1-1";"Auto"
"Lights1-6 Media mid FB";"5/1/11";"";"";"";"DPST-1-1";"Auto" "Lights1-6 Media mid FB";"5/1/11";"";"";"";"DPST-1-1";"Auto"
"Lights1-7 Media front SW";"5/1/12";"";"";"";"DPST-1-1";"Auto" "Lights1-7 Media front SW";"5/1/12";"";"";"";"DPST-1-1";"Auto"
"Lights1-7 Media front FB";"5/1/13";"";"";"";"DPST-1-1";"Auto" "Lights1-7 Media front FB";"5/1/13";"";"";"";"DPST-1-1";"Auto"
"Shutter";"5/2/-";"";"";"";"";"Auto" "HVAC";"5/2/-";"";"";"";"";"Auto"
"Heating";"5/3/-";"";"";"";"";"Auto" "LED night reduction";"5/4/-";"";"";"";"";"Auto"
"Timers";"5/4/-";"";"";"";"";"Auto"
"GF - Building Based";"6/-/-";"";"";"";"";"Auto" "GF - Building Based";"6/-/-";"";"";"";"";"Auto"
"Scene";"6/0/-";"";"";"";"";"Auto" "Scene";"6/0/-";"";"";"";"";"Auto"
"Lights1-2[34] Shower, all lights [SW]";"6/0/0";"";"";"Shower both lamps switching";"DPST-1-1";"Auto" "Lights1-2[34] Shower, all lights [SW]";"6/0/0";"";"";"Shower both lamps switching";"DPST-1-1";"Auto"
@ -101,6 +130,10 @@ Feedback received via NodeRed";"DPST-1-1";"Auto"
"Lights1-1[45] Kitchen, all lights [FB]";"6/0/3";"";"";"";"DPST-1-1";"Auto" "Lights1-1[45] Kitchen, all lights [FB]";"6/0/3";"";"";"";"DPST-1-1";"Auto"
"Lights[1-13,2-13] Hallway [SW]";"6/0/4";"";"";"";"DPST-1-1";"Auto" "Lights[1-13,2-13] Hallway [SW]";"6/0/4";"";"";"";"DPST-1-1";"Auto"
"Lights[1-13,2-13] Hallway [FB]";"6/0/5";"";"";"";"DPST-1-1";"Auto" "Lights[1-13,2-13] Hallway [FB]";"6/0/5";"";"";"";"DPST-1-1";"Auto"
"Lights1-1[78] Dining all lights [SW]";"6/0/6";"";"";"Dining room All";"DPST-1-1";"Auto"
"Lights1-1[78] Dining all lights [FB]";"6/0/7";"";"";"Dining room All";"DPST-1-1";"Auto"
"Lights1-[16,18,20,21] Living all [SW]";"6/0/8";"";"";"Living room All";"DPST-1-1";"Auto"
"Lights1-[16,18,20,21] Living all [FB]";"6/0/9";"";"";"Living room All";"DPST-1-1";"Auto"
"Lighting";"6/1/-";"";"";"";"";"Auto" "Lighting";"6/1/-";"";"";"";"";"Auto"
"Lights1-8 Guest, Ceiling lamp [SW]";"6/1/0";"";"";"Guest ceiling lamp switching";"DPST-1-1";"Auto" "Lights1-8 Guest, Ceiling lamp [SW]";"6/1/0";"";"";"Guest ceiling lamp switching";"DPST-1-1";"Auto"
"Lights1-8 Guest, Ceiling lamp [FB]";"6/1/1";"";"";"Guest ceiling lamp switching feedback";"DPST-1-1";"Auto" "Lights1-8 Guest, Ceiling lamp [FB]";"6/1/1";"";"";"Guest ceiling lamp switching feedback";"DPST-1-1";"Auto"
@ -156,8 +189,7 @@ Feedback received via NodeRed";"DPST-1-1";"Auto"
"Valve1-X Stairway [CTEMP 2.1.6]";"6/3/23";"";"";"Stairway GF";"DPST-9-1";"Auto" "Valve1-X Stairway [CTEMP 2.1.6]";"6/3/23";"";"";"Stairway GF";"DPST-9-1";"Auto"
"Valve1-X Slider [CTEMP 2.1.12]";"6/3/24";"";"";"Slider";"DPST-9-1";"Auto" "Valve1-X Slider [CTEMP 2.1.12]";"6/3/24";"";"";"Slider";"DPST-9-1";"Auto"
"Valve1-X Kitchen front [CTEMP 2.1.14]";"6/3/25";"";"";"Kitchen front";"DPST-9-1";"Auto" "Valve1-X Kitchen front [CTEMP 2.1.14]";"6/3/25";"";"";"Kitchen front";"DPST-9-1";"Auto"
"Timers";"6/4/-";"";"";"";"";"Auto" "LED night reduction";"6/4/-";"";"";"";"";"Auto"
"Current Time";"6/4/0";"";"";"";"DPST-10-1";"Auto"
"Led night reduction - Guest";"6/4/1";"";"";"";"DPST-1-1";"Auto" "Led night reduction - Guest";"6/4/1";"";"";"";"DPST-1-1";"Auto"
"Led night reduction - Hallway";"6/4/2";"";"";"";"DPST-1-1";"Auto" "Led night reduction - Hallway";"6/4/2";"";"";"";"DPST-1-1";"Auto"
"Led night reduction - Shower";"6/4/3";"";"";"";"DPST-1-1";"Auto" "Led night reduction - Shower";"6/4/3";"";"";"";"DPST-1-1";"Auto"

1 Group name Address Central Unfiltered Description DatapointType Security
2 Cellar - HVAC Global - Building Based 0/-/- Auto
3 Timers 0/0/- Auto
4 Current Time 0/0/1 DPST-10-1 Auto
5 Current date 0/0/2 DPST-11-1 Auto
6 Ventilation 0/1/- Auto
7 Ventilation SW 0/1/0 DPT-5 Auto
8 Ventilation FB 0/1/1 DPT-5 Auto
9 External setpoint SW 0/1/2 Auto
10 External setpoint FB 0/1/3 Auto
11 Boost SW 0/1/4 DPT-1 Auto
12 Boost FB 0/1/5 Auto
13 Boost time SW 0/1/6 DPT-7 Auto
14 Boost time FB 0/1/7 Auto
15 Temperature profile SW 0/1/8 DPT-5 Auto
16 Temperature profile FB 0/1/9 DPT-5 Auto
17 Temperature profile mode SW 0/1/10 DPT-5 Auto
18 Temperature profile mode FB 0/1/11 DPT-5 Auto
19 Away function SW 0/1/12 DPT-1 Auto
20 Away function FB 0/1/13 Auto
21 Ventilator preset 0 (Away) SW 0/1/14 DPT-1 Auto
22 Ventilator preset 1 SW 0/1/15 DPT-1 Auto
23 Ventilator preset 2 SW 0/1/16 DPT-1 Auto
24 Ventilator preset 3 SW 0/1/17 DPT-1 Auto
25 Ventilator preset 0 (Away) FB 0/1/18 DPT-1 Auto
26 Ventilator preset 1 FB 0/1/19 DPT-1 Auto
27 Ventilator preset 2 FB 0/1/20 DPT-1 Auto
28 Ventilator preset 3 FB 0/1/21 DPT-1 Auto
29 Auto mode SW 0/1/22 DPT-1 Auto
30 Auto mode FB 0/1/23 DPT-1 Auto
31 ComfoCool SW 0/1/24 DPT-1 Auto
32 ComfoCool FB 0/1/25 DPT-1 Auto
33 Ventilator preset SW 0/1/26 DPT-5 Auto
34 Ventilator preset FB 0/1/27 DPT-5 Auto
35 Temperature - Supply FB 0/1/28 DPT-9 Auto
36 Temperature - Exhaust FB 0/1/29 DPT-9 Auto
37 Temperature - Extract FB 0/1/30 DPT-9 Auto
38 Airflow FB 0/1/31 DPT-13 Auto
39 Media - HVAC 0/3/- Auto
40 Valve1-1 Media [CTEMP 1.3.10] 0/3/6 Wellness Lounge H DPST-9-1 Auto
41 Valve1-1 Media [SETPOINT TEMP] 0/3/7 Wellness Lounge H DPST-9-1 Auto
47 Valve1-2 Lounge [CMD] 0/5/4 Wellness HVAC - Lounge DPST-5-1 Auto
48 Valve1-2 Lounge [OP] 0/5/5 Wellness HVAC - Lounge DPST-20-102 Auto
49 Ground floor 2/-/- Auto
Dining 2/3/- Auto
Lights1-1[78] Dining all lights [SW] 2/3/4 Dining room All DPST-1-1 Auto
Lights1-1[78] Dining all lights [FB] 2/3/5 Dining room All DPST-1-1 Auto
Living 2/6/- Auto
Lights1-[16,18,20,21] Living all [SW] 2/6/8 Living room All DPST-1-1 Auto
Lights1-[16,18,20,21] Living all [FB] 2/6/9 Living room All DPST-1-1 Auto
50 First floor - HVAC 3/-/- Auto
51 Master bed - HVAC 3/1/- Auto
52 Valve2-2 Master bed [CTEMP 2.2.1] 3/1/14 Master HVAC DPST-9-1 Auto
119 Lights1-7 Media front SW 5/1/12 DPST-1-1 Auto
120 Lights1-7 Media front FB 5/1/13 DPST-1-1 Auto
121 Shutter HVAC 5/2/- Auto
122 Heating LED night reduction 5/3/- 5/4/- Auto
123 Timers GF - Building Based 5/4/- 6/-/- Auto
GF - Building Based 6/-/- Auto
124 Scene 6/0/- Auto
125 Lights1-2[34] Shower, all lights [SW] 6/0/0 Shower both lamps switching DPST-1-1 Auto
126 Lights1-2[34] Shower, all lights [FB] 6/0/1 Shower both lamps switching feedback Feedback received via NodeRed DPST-1-1 Auto
130 Lights[1-13,2-13] Hallway [FB] 6/0/5 DPST-1-1 Auto
131 Lighting Lights1-1[78] Dining all lights [SW] 6/1/- 6/0/6 Dining room All DPST-1-1 Auto
132 Lights1-8 Guest, Ceiling lamp [SW] Lights1-1[78] Dining all lights [FB] 6/1/0 6/0/7 Guest ceiling lamp switching Dining room All DPST-1-1 Auto
133 Lights1-[16,18,20,21] Living all [SW] 6/0/8 Living room All DPST-1-1 Auto
134 Lights1-[16,18,20,21] Living all [FB] 6/0/9 Living room All DPST-1-1 Auto
135 Lighting 6/1/- Auto
136 Lights1-8 Guest, Ceiling lamp [SW] 6/1/0 Guest ceiling lamp switching DPST-1-1 Auto
137 Lights1-8 Guest, Ceiling lamp [FB] 6/1/1 Guest ceiling lamp switching feedback DPST-1-1 Auto
138 Lights1-23 Shower, Ceiling lamp [SW] 6/1/2 Shower ceiling lamp switching DPST-1-1 Auto
139 Lights1-23 Shower, Ceiling lamp [FB] 6/1/3 Shower ceiling lamp switching feedback DPST-1-1 Auto
189 Valve1-X Kitchen front [CTEMP 2.1.14] 6/3/25 Kitchen front DPST-9-1 Auto
190 Timers LED night reduction 6/4/- Auto
191 Current Time Led night reduction - Guest 6/4/0 6/4/1 DPST-10-1 DPST-1-1 Auto
192 Led night reduction - Guest Led night reduction - Hallway 6/4/1 6/4/2 DPST-1-1 Auto
Led night reduction - Hallway 6/4/2 DPST-1-1 Auto
193 Led night reduction - Shower 6/4/3 DPST-1-1 Auto
194 Led night reduction - Kitchen 6/4/4 DPST-1-1 Auto
195 Led night reduction - Dining 6/4/5 DPST-1-1 Auto

View File

@ -23,6 +23,7 @@ mapping = {}
async def telegram_received_cb(telegram): async def telegram_received_cb(telegram):
"""Do something with the received telegram.""" """Do something with the received telegram."""
val = parse_message(config, mapping, telegram) val = parse_message(config, mapping, telegram)
publish_measurement(val) publish_measurement(val)

View File

@ -1,18 +1,24 @@
import csv import csv
import json import json
import json_fix from os import environ
import xknx.remote_value from xknx.dpt import DPT2ByteFloat, DPTBinary, DPTTime, DPTValue1ByteUnsigned, DPT4ByteUnsigned
import xknx
from xknx.dpt import DPT2ByteFloat, DPTBinary, DPTTime, DPTValue1ByteUnsigned
from datetime import datetime from datetime import datetime
class DPST: class DPST:
def __init__(self, str): def __init__(self, str):
vals = str.split('-') vals = str.split('-')
if len(vals) <= 1:
self.major = "1"
self.minor = "0"
return
self.major = vals[1] self.major = vals[1]
if len(vals) >=3:
self.minor = vals[2] self.minor = vals[2]
else:
self.minor = "0"
def __str__(self): def __str__(self):
return f"DPST {self.major}.{self.minor}" return f"DPST {self.major}.{self.minor}"
@ -50,6 +56,7 @@ def init_value_mapping():
config['9'] = { "value": DPT2ByteFloat, "type": "number" } config['9'] = { "value": DPT2ByteFloat, "type": "number" }
config['10'] = { "value": DPTTime, "type": "time" } config['10'] = { "value": DPTTime, "type": "time" }
config['5'] = { "value": DPTValue1ByteUnsigned, "type": "number" } config['5'] = { "value": DPTValue1ByteUnsigned, "type": "number" }
config['13'] = { "value": DPT4ByteUnsigned, "type": "number" }
return config return config
@ -103,5 +110,5 @@ if __name__ == '__main__':
from dotenv import load_dotenv from dotenv import load_dotenv
dotenv_path = join(dirname(__file__), '.env') dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path) load_dotenv(dotenv_path)
config = load_structure(os.environ.get('KNX_TOPOLOGY')) config = load_structure(environ.get('KNX_TOPOLOGY'))
print(json.dumps(config["6/4/0"], indent=2)) print(json.dumps(config["6/4/0"], indent=2))