change logging
This commit is contained in:
parent
e9420a4d76
commit
e6fdb70fd1
@ -15,7 +15,7 @@ import traceback
|
|||||||
from paho.mqtt import client as mqtt_client
|
from paho.mqtt import client as mqtt_client
|
||||||
import paho.mqtt.client as paho
|
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
|
Connected = False #global variable for the state of the connection
|
||||||
|
|
||||||
@ -33,27 +33,28 @@ client_id = "solarmonitor"
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
epd = epd2in13b_V3.EPD()
|
epd = epd2in13b_V3.EPD()
|
||||||
logging.info("init and Clear")
|
logging.debug("init and Clear")
|
||||||
epd.init()
|
epd.init()
|
||||||
epd.Clear()
|
epd.Clear()
|
||||||
time.sleep(1)
|
#time.sleep(1)
|
||||||
|
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
logging.info(e)
|
logging.info(e)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
logging.info("ctrl + c:")
|
logging.info("ctrl + c:")
|
||||||
|
epd.Clear()
|
||||||
epd2in13b_V3.epdconfig.module_exit()
|
epd2in13b_V3.epdconfig.module_exit()
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
def on_connect(client, userdata, flags, rc):
|
def on_connect(client, userdata, flags, rc):
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
print("Connected to MQTT Broker!")
|
logging.info("Connected to MQTT Broker!")
|
||||||
|
|
||||||
global Connected #Use global variable
|
global Connected #Use global variable
|
||||||
Connected = True #Signal connection
|
Connected = True #Signal connection
|
||||||
else:
|
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):
|
def on_message(client, userdata, msg):
|
||||||
global value_pvProduction
|
global value_pvProduction
|
||||||
@ -98,15 +99,11 @@ client.subscribe(topic_energyImportExport)
|
|||||||
client.subscribe(topic_houseBatterySoC)
|
client.subscribe(topic_houseBatterySoC)
|
||||||
client.subscribe(topic_houseBatteryLoadUnload)
|
client.subscribe(topic_houseBatteryLoadUnload)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
# Drawing on the image
|
logging.debug("Drawing")
|
||||||
logging.info("Drawing")
|
|
||||||
font10 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 12)
|
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
|
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
|
HRedimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 ryimage: red or yellow image
|
||||||
drawblack = ImageDraw.Draw(HBlackimage)
|
drawblack = ImageDraw.Draw(HBlackimage)
|
||||||
@ -123,16 +120,13 @@ try:
|
|||||||
drawblack.text((5, 30), 'Batterie Laden', font = font10, fill = 0)
|
drawblack.text((5, 30), 'Batterie Laden', font = font10, fill = 0)
|
||||||
else:
|
else:
|
||||||
drawred.text((5, 60), 'Batterie Entladen', font = font10, fill = 0)
|
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.debug("-----")
|
||||||
logging.info("test")
|
logging.debug("PvP: "+str(value_pvProduction))
|
||||||
logging.info("PvP: "+str(value_pvProduction))
|
logging.debug("Hou: "+str(value_wHouseConsumption))
|
||||||
logging.info("Hou: "+str(value_wHouseConsumption))
|
logging.debug("I/E: "+str(value_energyImportExport))
|
||||||
logging.info("I/E: "+str(value_energyImportExport))
|
logging.debug("SoC: "+str(value_houseBatterySoC))
|
||||||
logging.info("SoC: "+str(value_houseBatterySoC))
|
logging.debug("Bio: "+str(value_houseBatteryLoadUnload))
|
||||||
logging.info("Bio: "+str(value_houseBatteryLoadUnload))
|
|
||||||
#drawblack.rectangle((150, 0, 220, 50), fill = 255)
|
#drawblack.rectangle((150, 0, 220, 50), fill = 255)
|
||||||
drawblack.text((150, 0), str(value_pvProduction) + " W", font = font10, fill = 0)
|
drawblack.text((150, 0), str(value_pvProduction) + " W", font = font10, fill = 0)
|
||||||
#drawblack.rectangle((150, 15, 220, 50), fill = 255)
|
#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)
|
drawred.text((150, 60), str(value_houseBatteryLoadUnload) + " W", font = font10, fill = 0)
|
||||||
|
|
||||||
epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRedimage))
|
epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRedimage))
|
||||||
|
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("exiting")
|
logging.info("exiting")
|
||||||
client.disconnect()
|
client.disconnect()
|
||||||
client.loop_stop()
|
client.loop_stop()
|
||||||
|
Loading…
Reference in New Issue
Block a user