Controlling smart socket based on data change

I am trying to create a flow that turns a smart socket on and off based on the data that is received.

For example, if Temp <=15 turn on and if temp >=22 turn off.

I would also like to customise it further to only do it during certain times of day.

I have the data but am a bit stumped on where to go with it from there?

My thought was a function node, but up to this point cannot figure out how I would do it.

Any help or guidance would be greatly appreciated.

You don't say how you receive temperature data, nor how you control the smart socket so I'll assume you use MQTT.

Something like this should work

I used a simple logic gate node. No doubt it can be achieved without installing any custom nodes too.

1 Like

Yep or if you want to use custom nodes - then look at the node-red-contrib-sun-position (node) - Node-RED

It has a heap of nodes in there for time control - the one for you is within-time

Lets you compare the current time to a range of times/days and branch to one of two outputs depending on where the time is within the specific range or not.

You can just put that in front of @jbudd switch node above and you are good to go

Craig

1 Like

Thanks Craig - Shall have a look into this! Appreciate the suggestion!