question

falcon avatar image
falcon asked

How to keep MQTT Connection to Cerbo alive

I am using a Raspberry Pi with Homeassistant and MQTT. I wanna switch from Modbus to MQTT.

My problem is to hold the MQTT alive. My connection is working and I get every 3 sec. a data refresh (Controlled by a Desktop MQTT Explorer).

My conf file:

connection cerbo-home

address 192.168.1.201

keepalive_interval 10 (useless)

topic # both 0 cerbo-home/

But this works only as long a APP on iOS is open and hold the connection alive. After closing my App, the MQTT will close his connection and I see only my serial.

There are many manuals, and I´ve tried some of them, but nothing works.

Thank you for your help.

MQTTAssistants
2 |3000

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

1 Answer
axelenergie avatar image
axelenergie answered ·

Hello,

You need this command to make it works:

while :; do mosquitto_pub -h 192.168.1.205 -m '' -t 'R/<ID>/keepalive'; sleep 5; done

2 |3000

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