str to int

This commit is contained in:
Robert Borzutzki 2022-10-19 21:07:55 +02:00
parent 31da7421a2
commit f017c91f34

View File

@ -63,25 +63,25 @@ def on_message(client, userdata, msg):
global value_houseBatteryLoadUnload global value_houseBatteryLoadUnload
if msg.topic == "openWB/pv/W": if msg.topic == "openWB/pv/W":
value_pvProduction = ""+msg.payload.decode() value_pvProduction = int(msg.payload.decode())
elif msg.topic == "openWB/global/WHouseConsumption": elif msg.topic == "openWB/global/WHouseConsumption":
value_wHouseConsumption = ""+msg.payload.decode() value_wHouseConsumption = int(msg.payload.decode())
elif msg.topic == "openWB/evu/W": elif msg.topic == "openWB/evu/W":
value_energyImportExport = ""+msg.payload.decode() value_energyImportExport = int(msg.payload.decode())
elif msg.topic == "openWB/housebattery/%Soc": elif msg.topic == "openWB/housebattery/%Soc":
value_houseBatterySoC = ""+msg.payload.decode() value_houseBatterySoC = int(msg.payload.decode())
elif msg.topic == "openWB/housebattery/W": elif msg.topic == "openWB/housebattery/W":
value_houseBatteryLoadUnload = ""+msg.payload.decode() value_houseBatteryLoadUnload = int(msg.payload.decode())
client = mqtt_client.Client(client_id, protocol=paho.MQTTv31) 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
value_pvProduction = "" value_pvProduction = 0
value_wHouseConsumption = "" value_wHouseConsumption = 0
value_energyImportExport = "" value_energyImportExport = 0
value_houseBatterySoC = "" value_houseBatterySoC = 0
value_houseBatteryLoadUnload = "" value_houseBatteryLoadUnload = 0
client.on_message = on_message client.on_message = on_message