I only receive a topic if the value changes. This is OK except for very slow changing data. Any way to force a topic to send the current value
mqtt is not a database.
Topics are not “send” to the client. It’s the client that “subscribes” to topics.
Hence, when a client connects to the broker, the broker will supply the client with the topics it subscribes to.
If the same client reconnects while a topic (value) has not changed, the broker would not supply him with the same topic (value) again.
hence the client side should persist/remember the topic (last value) once received.
In case the topic is published with retained flag to the broker, a client could reconnect with a different client-ID and will be supplied with the last value regardless.
If you are using Node-Red on client side, this might help: GitHub - bartbutenaers/node-red-contrib-msg-resend: A Node Red node for resending flow messages
Also, read the documentation regarding dbus-mqtt and keep-alive: GitHub - victronenergy/dbus-flashmq: Plugin for FlashMQ that interfaces between DBUS and MQTT.
Got that thanks. Guess I will have to do a modbus call on startup else could take a long time to populate the stationary values
…as said, using keep-alive should do the trick right away, when starting: GitHub - victronenergy/dbus-flashmq: Plugin for FlashMQ that interfaces between DBUS and MQTT.
see:
To activate keep-alive, send a read request to
R/<portal ID>/keepalive
(or the legacyR/<portal ID>/system/0/Serial
). It will send all topics it has, whether the system is alive or not. This is the replacement for retained messages as used by the Python dbus-mqtt. Because messages are no longer retained, if you are subscribing to a path likeN/<portal ID>/+/+/ProductId
to see all products, you must initiate a keep-alive request afterwards to see the values. […]
When a keep-alive is received and all topics are published, the last topic will beN/<portal ID>/full_publish_completed
with a payload like{"value":1702459522}
. This topic signals that you have received all topics with their values, and can be a trigger for an application, to update the GUI, or go to the next state, etc.