Automate ceiling fans using temperature difference between sensors

For future reference, the home assistant Events:state node that you'd be using as a trigger has the ability to change the msg.topic without needing a change node. Just scroll down to Output Properties and you'll see msg.topic. Change it to a string and type whatever topic you'd like.

By default it is:
msg.topic = entity id

So in this case, using 2 different temp sensors, each would have a unique entity id so you should be able to output directly into the join node without having to use a change node to modify the topic.

Now if this were me, I would add an additional output property to your events:state node to create a flow variable.
On the 1st: flow.temp1=entity state
On the 2nd: flow.temp2=entity state
Doing it this way you can not only skip using the change node but also won't need the join node. You output them both directly to a function node and use the flow variables to do your calculation. It may sound more advanced but it's likely the simplest way to do this.

Thank you for your ideas, and I will certainly incorporate them on my next project. Presently, I have been able to use the function node to calculate the difference, but haven't had any success to create an output that will trigger the ceiling fan. Do you know how I would write the code in the function node to do this? Any help would be appreciated.
Connie

Before you can write the code you need to know what it has to do. What output do you want from the function?

As an extended comment on Colin's post, you need to know what commands / topics are required to be sent to the fan to get it working.

So the first question is, what type of control does it have (Tuya, zigbee, Tasmota, Sonoff, other)?

I need a call service to the fans which are wired to a tp-link wall switch. I want the fans to come on when the temperature difference between two sensors is 9 degrees and shut off when less than 9 degrees.
Thanks

What is a call service?

Is the wall switch one of these? https://www.kasasmart.com/us/products/smart-switches

There is a node available to control Tp-link kasa switches, the info page says " Under the hood, this uses TP-Link Smart Home API."
Someone has posted a flow too. Perhaps that will give you some hints on connecting your flow with the switch.

You may need a bit bigger difference.

If the difference is more than 9 the fan turns on.

If it is less than 9 it turns off....

I think you need to consider hysteresis.
(Basically it is, for example, turning off when the difference is less than 8)
This gives the program a range over which the program is active.

Otherwise it will (could) be turning on and off constantly.

Absolutely! I have experienced the on/off situation.

Ok.... It can cause complications/confusion if not expected.

Thank you everyone for your help. I was able to get the automation of the ceiling fans using temperature difference to work successfully. I'll post the solution soon

1 Like

Now that I've read all of this I'm curious what the solution was. :wink: