I am trying to figure out why a fan in my laundry room is not always triggered when the temperature in the room reaches a certain point.
Some days it works as expected and others it will not trigger for hours and the temperature rises will above the threshold.
The temperature sensor is off an ESPHome device, a Dallas sensor. The switch is an Aqara double switch. One runs the room light and the other the exhaust fan in the cieling (laundry room).
Most likely it’s because the temperature isn’t passing the threshold from a lower temp.
So if it’s 84 and it lowers to 83, it won’t trigger, it has to come from below 83 to trigger.
Have you checked the temp graph of the sensor when it doesn’t trigger?
Hmmm… I do have a chart showing the temps. Here is a screenshot, where yesterday it triggered a couple times and then nothing. It looks as though it was below 83 for some time and then it went above 83 and didn’t trigger.
Ok I see what you are saying and now that I know to search for that, I can see there are numerous posts about it that it only triggers when crossing the temp threshold from below the threshold and not if it never goes back below that threshold.
I haven’t yet found how to fix that though. I think in my case I have it set to be on for 25 minutes, but I guess I need to just leave it on until the temp drops below something like 81 degrees.
Have you considered triggering on a change in temperature and then put in a condition for being above the target temp. You can also make it reboot proof by checking for change in temp and condition below target temp to turn off fan.
# will switch state on above 25.6 °C and switch state off below 25.0 °C
binary_sensor:
- platform: threshold
name: 'Laundry fan'
entity_id: sensor.laundry_room
upper: 25.3
hysteresis: 0.3 # sensor
automation:
- alias: Laundry fan
trigger:
- platform: state
entity_id: binary_sensor.laundry_fan
to: null
action:
- service: switch.turn_{{ states("binary_sensor.laundry_fan") }}
target:
entity_id: switch.laundry_fan
I’ve used Choose instead of if so you can easily add more scenario’s in the future.
Disclaimer, I write this without testing, since I do not have your switches and sensors
If you don’t want the fan to run forever you can of course add your Fan off trigger and give it the id: Off.
The fan will be turned off. but if the temp never goes below 83, it will not be turned on again based on that trigger. You could add a trigger at fan x minutes off and give it an id of its own, i.e. ‘id: Timed_on’.
Then just add a choose option that has the condition:
temp above 83
triggered by ‘Timed_on’
and copy the same action as turn on. Of course one could combine both conditions in the first choose, but I think adding another choose option is easier to understand and trouble shoot for you.
Given that you didn’t test it, it was very close to working code. Just a couple typos. It looks to be working well for the past 24 hours. It has been very hot here so I expect it to stay on most of the day, and this automation does just that.