the fan is a basic window fan with a hardware switch I leave on then
I cut the power cord in half and put the sonoff relay in the middle and reflashed it with ESPHome
the temp sensor is an esp8266 esp-01 with a dht-11 connected to it also flashed with ESPHome
I can see the temp in my overview
I have a switch that works to turn the fan on and off in my overview
I have the devices working I need help with the automation
I would have the temp control (use hysteresis on the switch point) set a bit.
Have your manual control set another bit.
If either bit is on the fan is on
I would probably use generic thermostat for that. You just specify your sensor and switch in the config then you can adjust for what temperature you like. You may need to put it cooling mode.
You can get it to stay on by setting a really low temperature on the thermostat control.
I am guessing you probably don’t have an automation at all?
Ignoring your comment about “but if I turn on the fan manually i dont want the second one to turn it off again” for now a basic approach would be:
Once you have a basic automation working then look at improving and refining it.
You could replace the hard coded 70 with an input_number so you can adjust your set-point on the front end.
Or have a Condition, that if a heater is turned on, don’t run the fan etc as you will be dumping hot air outside.
But if you want to go the automation route, then @wills106’s suggestion is close. (I.e., I don’t think the value_template lines are needed or appropriate.)
And regarding your requirement “if I turn on the fan manually i dont want the second one to turn it off again”, that shouldn’t be an issue. If the temp goes above 70 it will already be on, so you won’t be turning in on manually. If it’s below 70, then the automation won’t turn it off until the temp first goes above 70 and then back below 70. Think of it this way: the triggers are “events”. I.e., the action will only run when the temp sensor crosses the threshold in the specified direction.