Function block to combine 2 analogue signals

I have a heating schedule with various set points during the day.

I want the option to manually override the current set point if required. This value will come from a different device.

I need a function block which takes these 2 inputs and outputs the value which has changed most recently.

Any thoughts how I can do this please?

Add Filter nodes to each of the two inputs so that you only get a message when the value changes. Then you can just feed the wires to the next node.

[Edit] In fact you may not need the Filter nodes, you only need them if messages with repeated values arrive down the wires.

Thanks, Colin, the filter block looks perfect.

So I can just connect the outputs of 2 filter blocks together and that works? I trained as a hardware engineer originally and I'm still adjusting to combining outputs together...

If the messages come independently (from separate sources), you can use the join node.

e.g.

event data 1 ---> add topic "v1" ---+---> Join ---> Use msg.payload.v1 and msg.payload.v2
event data 2 ---> add topic "v2" ---^


See this article in the cookbook for an example of how to join messages into one object.

If you make a request for values, you can simply put stuff in series and add extra properties to the msg or payload.

e.g. inject -> get value 1 -> copy payload to msg.v1 -> get value 2 -> copy payload to msg.v2 -> use msg.v1 and msg.v2 (in some logic node).

In short, you be able to use 2 values in some kind of comparison or logic, they should be in the same msg.

The OP just wants to pass on whichever message arrived most recently.

No need for filter, join or function nodes, just wire it up.

A junction node (does nothing)

Or

The filter is needed if the incoming messages may be repeated. The OP asked for them to be used only if the value changed.

I guess it's safe to assume that the "override" input can be passed on whenever it is entered by the user.
There may well be extra complexity if the "normal" input arrives every few minutes, in which case a filter may indeed be necessary to prevent it from overriding the override.
I assumed that "Normal" inputs would only arrive at the specified hours eg 16:00: 22, 22:00: 17, ... and in that case any normal input would override an earlier "override" input.

The original question is not a complete description of the requirement imho (sorry!).

True, but my suggestion is a complete solution to the problem as described.

Turns out the Tuya TRV value sometimes gets through even though it hasn't changed; I set up a WhatsApp to be sent on every 'change' and this peaked at 120 messages in one minute, all with the same value. (It then didn't see a 'change' for 4 hours. Odd)

Adding the Filter block as @jbudd suggested has stopped that. Only real changes get through now.

It's only been running a short while, but so far, its perfect.

Thanks to everyone who replied.