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"])…

--

--

--

--