Humidity spike automation

I have my bathroom fan controlled by HA. I’d like to create an automation that will detect a humidity spike over a short period of time, that would indicate someone is taking a shower, etc. The room is naturally humid, so I’m not looking for a threshold to cross, but do something like take a running average and look for a spike.

Have you seen anything like this? Not sure what hardware to get. I use both Insteon and Zwave devices, but wouldn’t object to a getting a cheap standalone as long as it is actually decent at measuring humidity.

I’ve made some temp/humidity sensor from a nodemcu and a DHT11 that works pretty good. However, if I had to do it over I’d probably use a DHT22 for better accuracy.

then you can use something like the trend binary sensor to set your threshold to trigger the automation.

I’m testing exactly the same thing - a fan with a Wemos D1 mini+DHT22 (esphome) controlled by HA logic.
The Trend binary sensor is a good idea, but currently I have my own 2-step gradient plus some binary sensors to decide when it’s time to start a fan - just because I didn’t have a look at HA components before starting my project :expressionless:

Here’s my control panel :slight_smile:

I like my setup and it works most of the time without me touching any settings in full auto mode (except situations when Wemos goes offline for some reason).
Still yet to share my project here though…
And ideally I’d convert it to a esphome-based one, i.e for it work independently, but with ability to be configured from HA. I hope it’s possible, but I’m not that advanced in esphome and simply cannot spend time now (as it will definitely take some time) to work on something that’s already working.

1 Like

@AhmadK @finity what did you use for communication? MQTT?

I originally started out creating an arduino sketch and using MQTT which worked perfectly fine.

However, I eventually started migrating my sonoff’s & shelly’s over to ESPHome using its API functionality so I figured I would just move all of my previous MQTT stuff to the API. So I moved my sensors to ESPHome as well.

What are shellys?

I’ve never used ESPHome before. How is that different than writing an Arduino sketch?

https://shelly.cloud/

ESPhome uses yaml to program the devices instead of the C style language of the Arduino. ESPHome is well integrated directly into HA so you don’t need a hub/broker to bridge the communications when using the API.

If you use Hassio there is an addon for ESPHome. I don’t use Hassio but I do use docker and there is an image that I run that I connect through the sidepanel that pulls up the dashboard. Or if you don’t want to access it like that you can easily just access it directly thru its webserver.

Once you do the initial upload (which requires a hard connection to the device) everything after that is all OTA updates.

It truly is the way to go if you use flashable Wifi devices with HA.

I’ve done everything through Arduino IDE, but I do like the ability to flash OTA, which I could never get working. What’s the image you use for docker?

nvm: found it!

esphome/esphome

nvm: you found it…:wink:

As @finity, I use ESPHome native API for my devices.
It’s a slightly different approach in a way, but it’s also very flexible, faster than MQTT so I like it and would definitely recommend.
The guys behind the project are great as well :wink:

@finity I’m probably going to try a bme280, as the reviewers I’ve come across swear by those over the DHT units.

Really excited to try ESPhome so I can let the Arduino be a sensor instead of mucking around with communications. Too bad there aren’t any Arduinos that run off of batteries for a significant amount of time.

Yeah, I’ve heard the same thing but for now I’ve already got these and they seem to be working OK. the humidity seems like it’s pretty accurate but the temp might be off a few degrees. I’ve never taken the time to do any kind of calibration on them.

Maybe I’ll get around to switching them over some day.

I have to say that I’m pretty happy with my DHT22 sensor as it mainly used to detect spikes in humidity, and it does it really well.

A bme280 is on its way to me, but it’s for different projects that require more accurate readings.

Well, I have quite a few standalone RF humidity/temperature sensors of the same model, and they give different readings even if placed side by side so I think you need either calibrate each one and keep that correction for them OR just say “my sensors can be off by N negrees/% from what’s actually there” and that’s still fine for DIY applications :wink:

@AhmadK in that case, could you please share your ESPhome code and automation to detect the spike? Because that’s exactly what I need, spike detection.

I understand. As you can see, there’s a lot of things and code involved, mainly because of my particular setup (RF wall switch).
I’m hoping to publish my project in the relevant section of this forum soon, just need to find some time… :wink:

@finity I ended up ordering a BME280 which seems to be pretty accurate for humidity. I used the AdaFruit bme280 library and the default bme280test example and the only modification I had to make was change the initialization command to status = bme.begin(0x76); and it started spitting out instant temperature, humidity, and pressure updates. Pretty cool.

So now that I’ve got some working Arduino code, I’m going to try and see if I can get the ESPHome BME280 sensor working with this.

1 Like

How is the temp accuracy?

Looks correct, but I’ll use my thermapen and get back to you. Now I’ve gotta figure out this gradient trend thing.

Can you share this project? I would love to see how you did this.

I’d love to, but not earlier than mid-September.
It’s still work in progress and has some things to improve, but I like it :wink: