Output value of a numeric node on dashboard when random input is triggered

So I have a simple node that ouputs the value of a numeric node via MQTT. The problem is that this value has to be outputed when the forceRefresh node (that is MQTT) triggers (and obvisously when the value is changed, but that is no problem). This node injects a random value the only purpose of it is to force this and other nodes to output their value so that the device on the other end can know the real values when it powers up.

With other nodes (like switch's) this isn't a problem. But in this node I don't see and option to output the existing value when a random input is triggered.

I know that what I'm trying to do is contradictory because sometimes the node will get an input from a useful value and other it will be random values. But I can't wrap my head around it

I don't fully understand what you are trying to do, but if you publish the values you need on startup to Retained MQTT topics then on power up anything subscribed to those topics will automatically receive the previous state from MQTT.

Maybe I haven't explained myself correctly. But anyway you have understood the essence of my problem.

So as I understand there is an option to automatically publish info when a device is connected? Because this is exactly what I'm intending to do.
If so, how could I do it?

Where you publish it set Retain true in the MQTT Out node. You will see it in the options if you look in the Out node settings.
Then whenever a client subscribes to that topic it will immediately get the most recent value.

1 Like

It might be worth your while looking through this MQTT tutorial as you may well find other useful features that you did not know about. The LWT feature, for example, can be extremely useful.

1 Like