How to do calulations in flows

I created an flow advanced flow that receives readings of 4 temperature sensors over MQTT. I defined variables to store the data and can also see graphs under Insights. I now want to calculate a temperature difference. I defined a variable dT and added a Logic Then card: Calculate Number variable as Text.

I selected the dT as the number variable and entered in the Text field: {{ t_leiding - t_ruimte}} where I selected the variables from the variables list.

I first connected this card to one of the branches that receives data from one of the sensors. This would hopefully lead to updates of dT every time that that specific variable is received. This did not give the desired result. So, I decided to add a branch with a timer card that fires every minute.

Also then, the chart of the difference dT does not show the expected variations. It shows a graph with a constant value most of the time.

Any suggestions?

I may have been too fast with getting help…

It looks that the flow shown in the pic does the job that I expected it to do.

1 Like