It depends on the exact wiring, but it sounds doable.
As far as the code goes, there are a number of different community-created smartapps that manage bathroom fans. It’s a popular use case.
Here is a simple one that only checks against humidity:
Smart Bathroom Fan
Bathroom fan automation can be tricky. If your house is anything like mine, it’s not exactly air tight. Seasonal changes in humidity can make it difficult to set specific relative humidity percentages at which to turn your bathroom exhaust fan on or off.
This SmartApp attempts to put some intelligence into the process by sampling the humidity in the room every five minutes and maintaining a rolling 24-hour average humidity. Your thresholds are then specified based on this average.
Features
This SmartApp does the following:
Turns on the fan when the humidity is more than X percent greater than the 24-hour average.
Turns off the fan when the humidity falls to within Y percent of the 24-hour average OR after an optional (but recommended) specified maximum amount …
And this one is more complicated and also looks at motion. The thread has a detailed discussion of how the humidity readings work on the smartthings sensor, which might be helpful.
Bathroom Light Control
Initial Release: 1.0.1
Controls bathroom lights:
Turn on light when motion is detected.
Turn off light after x minutes of no motion detection
Extend light off timer to x minutes if humidity sensor is above the average for the room and trending upward (shower in use?)
Developed / Tested with Aeon Multisensor which by default sends humidity every 8 minutes. We need to detect that humidity is rising with 1 reading as most people will want this to kick in by the 8 minute period and not 2 polls which would be 16 minutes. To do so we calculate the average temp over a period of readings (4 by default), then if the humidity is higher than the average and higher than the last reading, it is determined that humidity level is trending upward, so we adjust the off timer to…
And for anyone who hasn’t worked with custom code in smartthings before, here’s the FAQ on that.
The original FAQ information in this thread refers to the original smartthings architecture, which was in place through the end of 2022 and a little beyond. Custom code was written in the groovy programming language and ran in the smartthings cloud.
As of May 2023, you can no longer add new Groovy DTH‘s or smartapps to your smartthings account. So if you came here because of a link in an old forum thread, or on another site, I’m afraid the Groovy information is no longer usable.
All of this was replaced by a new architecture. Cloud to cloud integrations use the smartthings API. Hub connected devices, mostly Zigbee and zwave, now use “Edge Drivers,” written in the LUA programming language. Here’s the official announcement on those:
The process for using a custom Edge Driver in the new …
1 Like