feat: Proper configuration.
This commit is contained in:
parent
135802109e
commit
d52d6ec6d9
0
.dockerignore
Normal file
0
.dockerignore
Normal file
2
.env
2
.env
@ -4,4 +4,4 @@ KNX_TOPOLOGY=export-addresses.csv
|
||||
INFLUX_BUCKET=my_bucket
|
||||
INFLUX_ORG=example.com
|
||||
INFLUX_TOKEN=change_me
|
||||
INFLUX_URL=http://localhost:8086
|
||||
INFLUX_URL=http://10.0.0.27:40086
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
venv/
|
||||
requirements/
|
||||
__py*/
|
||||
__py*/
|
||||
.env
|
||||
./*.csv
|
12
Dockerfile
12
Dockerfile
@ -15,12 +15,8 @@ ENV INFLUX_TOKEN=change_me
|
||||
ENV INFLUX_URL=http://localhost:8086
|
||||
|
||||
COPY ./*.py /code/knx
|
||||
COPY ./.env /code/knx
|
||||
COPY ./defaults/.env /code/knx
|
||||
COPY ./defaults/export-addresses.csv /code/knx
|
||||
|
||||
|
||||
ENV CONFIG_STRUCTURE=/code/data/export-addresses.csv
|
||||
|
||||
VOLUME ["/code/data/export-addresses.csv", "/code/knx/.env"]
|
||||
|
||||
|
||||
CMD ["python", "knx_monitor.py"]
|
||||
CMD ["python", "knx_monitor.py"]
|
||||
# CMD ["ls", "-lsrtaR"]
|
9
db.py
9
db.py
@ -3,6 +3,7 @@ from influxdb_client.client.write_api import SYNCHRONOUS
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
from os.path import dirname, join
|
||||
dotenv_path = join(dirname(__file__), '.env')
|
||||
load_dotenv(dotenv_path)
|
||||
|
||||
@ -16,5 +17,9 @@ write_api = client.write_api(write_options=SYNCHRONOUS)
|
||||
|
||||
|
||||
def publish_measurement(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)
|
||||
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"])
|
||||
write_api.write(bucket=bucket, org=org, record=p)
|
||||
except Exception as e:
|
||||
print(f"Could not send value {value} to {url}")
|
||||
print(e)
|
1
defaults/export-addresses.csv
Normal file
1
defaults/export-addresses.csv
Normal file
@ -0,0 +1 @@
|
||||
"Group name";"Address";"Central";"Unfiltered";"Description";"DatapointType";"Security"
|
|
@ -3,6 +3,8 @@ import asyncio
|
||||
import getopt
|
||||
import sys
|
||||
|
||||
import os
|
||||
from os.path import dirname, join
|
||||
from xknx import XKNX
|
||||
from xknx.io import ConnectionConfig, ConnectionType
|
||||
from xknx.telegram import AddressFilter
|
||||
@ -18,9 +20,6 @@ from db import publish_measurement
|
||||
config = {}
|
||||
mapping = {}
|
||||
|
||||
|
||||
|
||||
|
||||
async def telegram_received_cb(telegram):
|
||||
"""Do something with the received telegram."""
|
||||
val = parse_message(config, mapping, telegram)
|
||||
|
@ -56,6 +56,7 @@ def init_value_mapping():
|
||||
|
||||
|
||||
def load_structure(filename):
|
||||
print(f"Configuration file: {filename}")
|
||||
config = {}
|
||||
with open(filename, newline='') as csvFile:
|
||||
line = 0
|
||||
@ -98,6 +99,7 @@ def parse_message(structure, mapping, telegram):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from os.path import dirname, join
|
||||
from dotenv import load_dotenv
|
||||
dotenv_path = join(dirname(__file__), '.env')
|
||||
load_dotenv(dotenv_path)
|
||||
|
Loading…
Reference in New Issue
Block a user