From f017c91f34e1e1afe8759bf7181ca92e1116e151 Mon Sep 17 00:00:00 2001 From: Robert Borzutzki Date: Wed, 19 Oct 2022 21:07:55 +0200 Subject: [PATCH] str to int --- examples/mqtt.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/mqtt.py b/examples/mqtt.py index e98566b..aaa130a 100644 --- a/examples/mqtt.py +++ b/examples/mqtt.py @@ -63,25 +63,25 @@ def on_message(client, userdata, msg): global value_houseBatteryLoadUnload if msg.topic == "openWB/pv/W": - value_pvProduction = ""+msg.payload.decode() + value_pvProduction = int(msg.payload.decode()) elif msg.topic == "openWB/global/WHouseConsumption": - value_wHouseConsumption = ""+msg.payload.decode() + value_wHouseConsumption = int(msg.payload.decode()) elif msg.topic == "openWB/evu/W": - value_energyImportExport = ""+msg.payload.decode() + value_energyImportExport = int(msg.payload.decode()) elif msg.topic == "openWB/housebattery/%Soc": - value_houseBatterySoC = ""+msg.payload.decode() + value_houseBatterySoC = int(msg.payload.decode()) 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.username_pw_set(username, password=pw) client.on_connect = on_connect -value_pvProduction = "" -value_wHouseConsumption = "" -value_energyImportExport = "" -value_houseBatterySoC = "" -value_houseBatteryLoadUnload = "" +value_pvProduction = 0 +value_wHouseConsumption = 0 +value_energyImportExport = 0 +value_houseBatterySoC = 0 +value_houseBatteryLoadUnload = 0 client.on_message = on_message