Skip to content

Commit

Permalink
optimized troubleshooting
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-manuel committed Mar 1, 2023
1 parent a401e43 commit c20a0e1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions dbus-mqtt-grid/dbus-mqtt-grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# set variables
connected = 0

grid_power = 0
grid_power = -1
grid_current = 0
grid_voltage = 0
grid_forward = 0
Expand Down Expand Up @@ -86,7 +86,11 @@ def on_connect(client, userdata, flags, rc):
def on_message(client, userdata, msg):
try:

global grid_power, grid_current, grid_voltage, grid_forward, grid_reverse, grid_L1_power, grid_L1_current, grid_L1_voltage, grid_L1_forward, grid_L1_reverse, grid_L2_power, grid_L2_current, grid_L2_voltage, grid_L2_forward, grid_L2_reverse, grid_L3_power, grid_L3_current, grid_L3_voltage, grid_L3_forward, grid_L3_reverse
global \
grid_power, grid_current, grid_voltage, grid_forward, grid_reverse, \
grid_L1_power, grid_L1_current, grid_L1_voltage, grid_L1_forward, grid_L1_reverse, \
grid_L2_power, grid_L2_current, grid_L2_voltage, grid_L2_forward, grid_L2_reverse, \
grid_L3_power, grid_L3_current, grid_L3_voltage, grid_L3_forward, grid_L3_reverse
# get JSON from topic
if msg.topic == config['MQTT']['topic_meters']:
if msg.payload != '{"value": null}' and msg.payload != b'{"value": null}':
Expand Down Expand Up @@ -267,9 +271,14 @@ def main():
client.loop_start()

# wait to receive first data, else the JSON is empty and phase setup won't work
while grid_power == 0:
logging.info("Waiting 5 seconds for receiving first data...")
i = 0
while grid_power == -1:
if i % 12 != 0 or i == 0:
logging.info("Waiting 5 seconds for receiving first data...")
else:
logging.warning("Waiting since %s seconds for receiving first data..." % str(i * 5))
time.sleep(5)
i += 1


#formatting
Expand Down

0 comments on commit c20a0e1

Please sign in to comment.