change logging

This commit is contained in:
Robert Borzutzki 2022-10-19 21:25:00 +02:00
parent e9420a4d76
commit e6fdb70fd1

View File

@ -15,7 +15,7 @@ import traceback
from paho.mqtt import client as mqtt_client
import paho.mqtt.client as paho
logging.basicConfig(level=logging.DEBUG)
logging.basicConfig(level=logging.INFO)
Connected = False #global variable for the state of the connection
@ -33,27 +33,28 @@ client_id = "solarmonitor"
try:
epd = epd2in13b_V3.EPD()
logging.info("init and Clear")
logging.debug("init and Clear")
epd.init()
epd.Clear()
time.sleep(1)
#time.sleep(1)
except IOError as e:
logging.info(e)
except KeyboardInterrupt:
logging.info("ctrl + c:")
epd.Clear()
epd2in13b_V3.epdconfig.module_exit()
exit()
def on_connect(client, userdata, flags, rc):
if rc == 0:
print("Connected to MQTT Broker!")
logging.info("Connected to MQTT Broker!")
global Connected #Use global variable
Connected = True #Signal connection
else:
print("Failed to connect, return code %d\n", rc)
logging.debug("Failed to connect, return code %d\n", rc)
def on_message(client, userdata, msg):
global value_pvProduction
@ -98,15 +99,11 @@ client.subscribe(topic_energyImportExport)
client.subscribe(topic_houseBatterySoC)
client.subscribe(topic_houseBatteryLoadUnload)
try:
while True:
# Drawing on the image
logging.info("Drawing")
logging.debug("Drawing")
font10 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 12)
# Drawing on the Horizontal image
logging.info("1.Drawing on the Horizontal image...")
HBlackimage = Image.new('1', (epd.height, epd.width), 255) # 298*126
HRedimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 ryimage: red or yellow image
drawblack = ImageDraw.Draw(HBlackimage)
@ -123,16 +120,13 @@ try:
drawblack.text((5, 30), 'Batterie Laden', font = font10, fill = 0)
else:
drawred.text((5, 60), 'Batterie Entladen', font = font10, fill = 0)
#epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRedimage))
#epd.display(epd.getbuffer(HBlackimage))
print("-----")
logging.info("test")
logging.info("PvP: "+str(value_pvProduction))
logging.info("Hou: "+str(value_wHouseConsumption))
logging.info("I/E: "+str(value_energyImportExport))
logging.info("SoC: "+str(value_houseBatterySoC))
logging.info("Bio: "+str(value_houseBatteryLoadUnload))
logging.debug("-----")
logging.debug("PvP: "+str(value_pvProduction))
logging.debug("Hou: "+str(value_wHouseConsumption))
logging.debug("I/E: "+str(value_energyImportExport))
logging.debug("SoC: "+str(value_houseBatterySoC))
logging.debug("Bio: "+str(value_houseBatteryLoadUnload))
#drawblack.rectangle((150, 0, 220, 50), fill = 255)
drawblack.text((150, 0), str(value_pvProduction) + " W", font = font10, fill = 0)
#drawblack.rectangle((150, 15, 220, 50), fill = 255)
@ -151,10 +145,9 @@ try:
drawred.text((150, 60), str(value_houseBatteryLoadUnload) + " W", font = font10, fill = 0)
epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRedimage))
time.sleep(10)
except KeyboardInterrupt:
print("exiting")
logging.info("exiting")
client.disconnect()
client.loop_stop()