TL;DR package Java drivers and class in a container, run it with environment variables
Here we go:
1 Java class only and the possibility to run every query you like.
Want to use a different database?
Code is already prepared for it, just use different drivers in pom.xml :-) (and maybe rename the env variables)
Hier ein Beispiel wie Werte in die Datenbank geschrieben und gelesen werden können (Verwendung TimescaleDB um Metriken zu speichern):
Der Tabellenname ist fest codiert, aber der Ansatz sollte verständlich sein :-)
#Verbindungsaufbau
TimescaleDb.connect(timescaledb_ip, timescaledb_username, timescaledb_password)#Metrik speichern (Tabellenname fest vergeben)
TimescaleDb.write('my_id', my_value)#Wert aus einer Tabelle lesen (hier ohne Where Bedingung)
TimescaleDb.read('my_single_value_table')#Wert in einer Tabelle erhöhen (hier ohne Where Bedingung)
TimescaleDb.increase('my_single_value_table', addition, max_value)
Here you can find an easy example to handle database connectivity in Python (used with TimescaleDB to save metrics):
I hardcoded my table name, but I think you can get the approach :-)
#connect to database
TimescaleDb.connect(timescaledb_ip, timescaledb_username, timescaledb_password)#write a single metric value (hardcoded table)
TimescaleDb.write('my_id', my_value)#read value from a table (in this case without where)
TimescaleDb.read('my_single_value_table')#increase value of the table (in this case without where)
TimescaleDb.increase('my_single_value_table', addition, max_value)
Features:
- Tasmota ein- und ausschalten
- Status Werte von Tasmota abfragen
#Verbindung zum MQTT broker
Tasmota.connect(mqtt_broker, mqtt_port, mqtt_user, mqtt_password)#Einschalten (bitte im Tasmota konfigurierten Topic Name verwenden)
Tasmota.on(topic_name)#Ausschalten (bitte im Tasmota konfigurierten Topic Name verwenden)
Tasmota.off(topic_name)#Status Information lesen (JSON in flache Struktur umgewandelt)
Tasmota.get(topic_name, "8", ["StatusSNS_SI7021_Temperature"])
Tasmota.get(topic_name, "8", ["StatusSNS_ENERGY_Power", "StatusSNS_ENERGY_Today"])
You can use this Python module to
- switch Tasmota device on/off
- read status values from Tasmota device
#connect to MQTT broker
Tasmota.connect(mqtt_broker, mqtt_port, mqtt_user, mqtt_password)#switch on (please use the topic name configured in Tasmota)
Tasmota.on(topic_name)#switch off (please use the topic name configured in Tasmota)
Tasmota.off(topic_name)#read status information (flattened json result)
Tasmota.get(topic_name, "8", ["StatusSNS_SI7021_Temperature"])
Tasmota.get(topic_name, "8", ["StatusSNS_ENERGY_Power", "StatusSNS_ENERGY_Today"])
Ich habe ein kleines Python Program geschrieben, das meinen Solarüberschuss an meine iDM AERO SLM 6–17 Wärmepumme schickt. Die Pumpe füllt damit automatisch den Wärmespeicher und reguliert die Räume auf Wohlfühltemperatur — die kostenlose Energie wird sinnvoll genutzt.
In der iDM muss das PV-Eingangssignal für Photovoltaik auf “Gebäudeleittechnik / Smartfox” gesetzt werden.
Hier der Code:
Man muss nur die IP und den Port (typischerweise 502) wissen um die Info zu senden.
IdmPump.writeandread(deine_ip, 502, dein_wert)
I realized a small Python module to send my actual solar energy generation every 30 sec to iDM AERO SLM 6–17 heat pump. Pump will automatically fill my hot water storage and rooms when sun energy is available.
In iDM you need to configure PV signal as “Gebäudeleittechnik / Smartfox” (Sorry I just have the German wording in my iDM GUI)
Here’s the code:
You just need to know the IP and port (typically 502) to send the information.
IdmPump.writeandread(your_ip, 502, your_value)