import asyncio import logging import sys import mysql.connector as mc from mysql.connector import connect, Error import konfig from dataclasses import dataclass _LOGGER = logging.getLogger(__name__) @dataclass class WaterData: waterHeight:int = 0 temp:float = 0 async def getWaterData(): ret = WaterData try: with connect(**konfig.datenbank()) as connection: query = ("SELECT water_mm, temp_c FROM zisterne WHERE datetime > DATE_SUB(NOW(),INTERVAL 10 MINUTE) ORDER BY ID DESC LIMIT 1;") with connection.cursor() as cursor: cursor.execute(query) myresult = cursor.fetchone() connection.commit() ret.waterHeight = myresult[0] ret.temp = myresult[1]/10 except: #_LOGGER.warning("Water data could not be fetched") return ret return ret #result = await vehicle.remote_services.trigger_remote_light_flash() #print(result.state)