question

ivan avatar image
ivan asked

MQTT subscription to ESS schedules stop answering

Hey!
I'm writing a Python script to fetch data from the ESS schedules automatically.

def on_connect(client: mqtt.Client, userdata, flags, rc):
    client.subscribe("N/%s/system/0/Serial" % portal_id)
    client.subscribe("N/%s/settings/0/Settings/CGwacs/BatteryLife/Schedule/Charge/%d/Day" % (portal_id, num))
def on_message(client, userdata, msg):
    val = json.loads(msg.payload)
    print(msg.topic+" -> "+str(val))

It works fine if I have my Remote Console open on the browser, but if I close it or leave the tab - after a ~0.5-1min mqtt subscription does not return any values.

/system/0/Serial though works fine at any time not depending on an open/close state on the web page.

Have someone faced the same issue?

Maybe there is a way to ping/send keepalive?


I really appreciate any help you can provide.

Best,

Ivan

MQTTpython
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

2 Answers
paul-campbell avatar image
paul-campbell answered ·

That is the correct proceedure for a "keep alive" bus.

I have an "on_clock" call back which fires off a local clock every second.

I do:

if clock % 5 == 0:

publish_client.publish("venus-home/R/b827exxxxf99/keepalive", "")

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

ivan avatar image
ivan answered ·

Achieved a "ping" functionality by:

client.publish("R/%s/system/0/Serial" % portal_id)

If there are any better solutions - please share :)

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources

Victron MQTT readme

Additional resources still need to be added for this topic