add log
This commit is contained in:
		
							parent
							
								
									463149a2ab
								
							
						
					
					
						commit
						4c8537d015
					
				@ -71,21 +71,26 @@ def on_connect(client, userdata, flags, rc):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
def on_message(client, userdata, msg):
 | 
					def on_message(client, userdata, msg):
 | 
				
			||||||
    if msg.topic == "openWB/pv/W":
 | 
					    if msg.topic == "openWB/pv/W":
 | 
				
			||||||
 | 
					        value_pvProduction = msg.payload.decode()
 | 
				
			||||||
        line = 0
 | 
					        line = 0
 | 
				
			||||||
    elif msg.topic == "openWB/global/WHouseConsumption":
 | 
					    elif msg.topic == "openWB/global/WHouseConsumption":
 | 
				
			||||||
 | 
					        value_wHouseConsumption = msg.payload.decode()
 | 
				
			||||||
        line = 15
 | 
					        line = 15
 | 
				
			||||||
    elif msg.topic == "openWB/evu/W":
 | 
					    elif msg.topic == "openWB/evu/W":
 | 
				
			||||||
 | 
					        value_energyImportExport = msg.payload.decode()
 | 
				
			||||||
        line = 30
 | 
					        line = 30
 | 
				
			||||||
    elif msg.topic == "openWB/housebattery/%Soc":
 | 
					    elif msg.topic == "openWB/housebattery/%Soc":
 | 
				
			||||||
 | 
					        topic_houseBatterySoC = msg.payload.decode()
 | 
				
			||||||
        line = 45
 | 
					        line = 45
 | 
				
			||||||
    elif msg.topic == "openWB/housebattery/W":    
 | 
					    elif msg.topic == "openWB/housebattery/W":  
 | 
				
			||||||
 | 
					        topic_houseBatteryLoadUnload = msg.payload.decode()  
 | 
				
			||||||
        line = 60
 | 
					        line = 60
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    print(line)
 | 
					    print(line)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    drawblack.rectangle((150, line, 220, 50), fill = 255)
 | 
					    drawblack.rectangle((150, line, 220, 50), fill = 255)
 | 
				
			||||||
    drawblack.text((150, line), msg.payload.decode(), font = font10, fill = 0)
 | 
					    drawblack.text((150, line), msg.payload.decode(), font = font10, fill = 0)
 | 
				
			||||||
    epd.DisplayPartial(epd.getbuffer(HBlackimage))
 | 
					    epd.DisplayPartial(epd.getbuffer(HBlackimage))
 | 
				
			||||||
    time.sleep(10)
 | 
					 | 
				
			||||||
    #print(f"`{msg.topic}`: `{msg.payload.decode()}`")
 | 
					    #print(f"`{msg.topic}`: `{msg.payload.decode()}`")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Connected = False   #global variable for the state of the connection
 | 
					Connected = False   #global variable for the state of the connection
 | 
				
			||||||
@ -98,6 +103,12 @@ topic_energyImportExport = "openWB/evu/W"
 | 
				
			|||||||
topic_houseBatterySoC = "openWB/housebattery/%Soc"
 | 
					topic_houseBatterySoC = "openWB/housebattery/%Soc"
 | 
				
			||||||
topic_houseBatteryLoadUnload = "openWB/housebattery/W"
 | 
					topic_houseBatteryLoadUnload = "openWB/housebattery/W"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					value_pvProduction = 0
 | 
				
			||||||
 | 
					value_wHouseConsumption = 0
 | 
				
			||||||
 | 
					value_energyImportExport = 0
 | 
				
			||||||
 | 
					value_houseBatterySoC = 0
 | 
				
			||||||
 | 
					value_houseBatteryLoadUnload = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
username = "mqtt-user"
 | 
					username = "mqtt-user"
 | 
				
			||||||
pw = "phio6yiR9ohs1veeghu4WaeGhaiRi8he4EiWasheev4faeku8tohdiuthah7zahP"
 | 
					pw = "phio6yiR9ohs1veeghu4WaeGhaiRi8he4EiWasheev4faeku8tohdiuthah7zahP"
 | 
				
			||||||
client_id = "solarmonitor"
 | 
					client_id = "solarmonitor"
 | 
				
			||||||
@ -106,7 +117,7 @@ client = mqtt_client.Client(client_id, protocol=paho.MQTTv31)
 | 
				
			|||||||
client.username_pw_set(username, password=pw)
 | 
					client.username_pw_set(username, password=pw)
 | 
				
			||||||
client.on_connect = on_connect
 | 
					client.on_connect = on_connect
 | 
				
			||||||
client.on_message = on_message
 | 
					client.on_message = on_message
 | 
				
			||||||
 | 
					logging.info("test")
 | 
				
			||||||
client.connect(broker, port=port)
 | 
					client.connect(broker, port=port)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
client.loop_start()        #start the loop
 | 
					client.loop_start()        #start the loop
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user