Setting message payload based on condition

I am measuring temp diff and saving it to flow context value 'Temp-Diff'. I then would like to use that context value to turn sonoff "on" or "off" by setting message payload accordingly and at a next step sending that message via mqtt. It should turn sonoff 'on' if temperature difference (TempD) is higher than 8. Here is the code that I use within function node :

var TempD = flow.get("Temp-Diff") || 0;
if (TempD > 8){msg.payload='on';}
if (TempD <= 8){msg.payload='off';}
return msg;

I have then started inject note with timestamp every 1 minute. Thought temp diff would be checked every minute and depending on value would either turn sonoff 'on' or 'off'. Howerver, I can see that sonoff is not reacticting to tempD value and simply turns on and off every minute

Please stick to one thread - posting the same question in two places causes confusion.

Link to other thread here