Dynamically reading external MQTT feed

Hi All,

I would like to read an MQTT feed from my solar power system dynamically in OH2.

I have done the following:

  • Setup a MQTT broker in my mqtt.cfg - works. (KeepAlive set to 120s)
  • Setup a String item with the MQTT path - works.

My questions:

  • How do I send a regular “Keep Alive” message? The external mqtt broker is setup to go to sleep if no such message is received to conserve power/cpu. Something like: “R/1a2b3c4d5e6f/system/0/Serial” needs to be sent regularly to receive the feeds.
  • How do I have the String item in my sitemap refresh continiously to get the latest readout?

I have tested the above - if I send the KeepAlive manually and refresh my UI I can actually see the value as a once off.

I have really searched - but cannot find any answer. Please assist.

Ed

Use a Rule with a Time cron trigger to periodically publish the String on the Item linked to the Keep Alive topic.

With MQTT typically you have an Item subscribed to the topic with the feed. Any messages published to that topic is processed and updates the Item’s state.

Perhaps if you post your Item config it will be more clear what you are trying to do and/or if there are errors.

Is there no way to configure the broker to no go to sleep?

The MQTT binding documentation is here.