Hello,
I have installed a temperature DS18b20 sensor on a hot water pipe.
I monitor the rise of the temperature when I turn on the hot water and I can tell that the bathroom is occupied (someone is having a shower).
It works ok. The raise of the temperature is pretty fast (within 1-2 minutes) and I am happy with it.
I use a template sensor within Esphome which I turn on when temperature raises above 25°C
switch:
- platform: template
name: "shower is occupied"
id: shower_occupied
optimistic: true
sensor:
- platform: dallas
address: 0x41b6a40d1e64ff28
name: "Attic cold water pipe"
- platform: dallas
address: 0xa5e4eb0d1e64ff28
name: "Attic hot water pipe"
on_value_range:
- above: 25.0
then:
- switch.turn_on: shower_occupied
- below: 25.0
then:
- switch.turn_off: shower_occupied
- platform: wifi_signal
name: "WiFi Signal Sensor"
update_interval: 1800s ###update every 30 min.
When I do this, I consider that the bathroom is occupied.-
When the pipe is hot it takes time to cool out again.
So I am looking a way to turn off the switch faster than it usually takes to go bellow 25°C.
(bellow 25°C I consider that the shower has finished)
Please note, that it takes some time, as it goes up to 35°C when hot water is running through the pipe.
It usually takes about 20-30 min to cool down.
I was thinking for a way to keep track when the temperature starts to decrease.
So if it goes from 35 to 34 and then to 33.5 and then to 32 I can turn off the switch and don’t have to wait untill it goes bellow 25°C.
I know that there are 1000 different ways to achieve the following requirement, but I don’t want any plumbing intervation…
This photo might help. By the way I just tried to take a fresh photo for you and the lamp burned out!!
The sensor is attached exactly where the arrow points.
the easiest would probably be to actually add a second sensor like a PIR or use a condition like the light for example. So, if pipe is hot and (average shower time) has passed and PIR state is off or light is off Then, shower isn’t occupied. If it takes 30 min to actually start cooling off enough to detect then your only options are use multiple sensor or cut the pipe and add a flow meter. It’s really only takes little effort to add a flow meter plus you could use the same board as the dallas sensor and you get to track water use and make cool charts!!
I would not use the yaml switch you have in esp home but instead look at the temperature sensor in HA.
Not sure which is best but statistics, derivative or trend sensor.
One or all of them might show if the temperature is going up or down.
Then you can use this in a template, if temperature going down or below 25 then off, if temperature going up or above 25 then on.
it doesn’t matter what statistics are available in HA. The Dallas sensor is sending its values to HA and thats the only numbers HA has to work with, it doesn’t magically get data before esphome sends it the data… Adding an air gap between the dallas sensor and the pipe plus changing the update_interval to less than 60s will help though.
the other problem is if its on the hot water intake side, when the water is shut off in the shower all of that hot water stays in the system and it keeps that pipe warm untill the actual water temperature in the pipe cools down which is why its taking 30 min to see a temp change. I’m with you on changing it to the drain side because that water isn’t going to just sit in that pipe, its going cool down very rapidly.
But having a switch called shower_occupied will be very confusing if it still has the above below 25 degree threshold.
That is why I said remove that and use the sensor data instead and create a new template sensor.
Here are the graphs for a long and a short shower. Humidity will begin dropping within 5 minutes of shower going off. Even if shower is with window open or extractor fan on the humidity will go up and down quicker than temperature.
First of all thank you very much everybody, for your suggestions and your ideas.
Here are my remarks
Humidity sensor is not an option. Of course I already have one, but it is not always accurate as I live at an island and the humidity is problem … Sometimes humidity at the bathroom is too high even though nobody is using the shower! I use it among with trend and deritative sensors but not always accurrate in my situation.
PIR sensor is not an option too …Not always accurate.
If you don’t move it might trigger the wrong information …
Cut the pipe and add a flow meter is the solution, I know this. But not an option for me.
I want to avoid the plumbing work. Another reason is that the pipes are at attic and a water leak will cause us big house troubles.
After extensive tests, I now know when someone is having a shower within 1-2 minutes which is very cool. This is how long it takes until pipe’s temperature rising above 25.
It works smoothly. For this I am using the following code:
Am very happy with it!
Because now, the most of the times, I will not switch off the lights automatically at night when someone is having a shower. But what about when the shower has finished … nobody is at the shower ???
Sensor will remain ON until it cools down…so the lights too.
Like @Hellis81 I was thinking to use a maximum sensor and a template.
Something like this
With a template like this I don’t have to wait the pipe to cool down.
I will only wait for about 5 minutes until temperature drops 3°C from the max. temperature
When this condition is true, I can manually switch off sensor.shower_is_occupied.
I’ve been struggling to create a Maximum value sensor … which I will be able to use as above. Max/Min helper can’t be used as it requires two sensors. Derivative sensor not always accurate as I want a small time window and Dallas might not get updated.
I found this article which records Min and Max values within ESPHOME.
It uses a Lambda function with C++ code.
Not my expertise. Tried to implement it for my case but it didn’t work …
Any help please ?? Other suggestions to get Highest temperature and monitor when it is falling ???
I think your best bet for accurate monitoring is to put a water flow switch in-line, which is also the usual method used to turn on a shower pump. Something like this uses a magnet and could be connected to your ESP device through a GPIO pin. If you already have a shower pump then you could measure the power draw as a trigger. I do this as an additional trigger to humidity as it works faster.
Humidity is also a good option for sensing shower usage, especially if you want to control a fan. You just need to allow for the base humidity changing. There are template sensors you can use such as derivative but for ease of use I would go for the HACS module Generic Hygrostat (not to be confused with the home assistant Generic Hygrostat). I have been using the HACS version for over 2 years now on a couple of showers to control a fan and off the and it works great.
This is the code I added to my configuration.yaml
# Bathroom and Ensuite Humidity Monitoring
binary_sensor:
- platform: generic_hygrostat
name: Bathroom Hygrostat
sensor: sensor.bathroom_weather_humidity # Source humidity sensor
delta_trigger: 5 # Optional humidity swing to detect. Default = 3
target_offset: 3 # Optional dehumidification target offset. Default = 3
min_on_time: 300 # Optional min on time in seconds. Default = 0 seconds
max_on_time: 10800 # Optional safety max on time in seconds. Default = 7200 seconds
sample_interval: 60 # Optional time between taking humidity samples in seconds, default 300 seconds
min_humidity: 30 # Optional minimum humidity to enable dehumidification. Default = 0
- platform: generic_hygrostat
name: Ensuite Hygrostat
sensor: sensor.ensuite_weather_humidity # Source humidity sensor
delta_trigger: 5 # Optional humidity swing to detect. Default = 3
target_offset: 3 # Optional dehumidification target offset. Default = 3
min_on_time: 300 # Optional min on time in seconds. Default = 0 seconds
max_on_time: 10800 # Optional safety max on time in seconds. Default = 7200 seconds
sample_interval: 60 # Optional time between taking humidity samples in seconds, default 300 seconds
min_humidity: 30 # Optional minimum humidity to enable dehumidification. Default = 0
You have plastic pipes , so you could try esp32 touch capacitance sensor on one side of pipe and ground wire connected to other side of pipe. The pipe will always be full of water I think but hot water may affect the capacitance compared to cold water and even flowing liquid make be different to static. A plastic pipe that is empty compared to full would give much bigger difference rapidly.
This shows the esphome code for ESP32. Just a wire connected to esp32 at one end and other to pipe. Make the surface area in contact with the pipe larger, like wrapping a bit of foil to it. A similar wire to ground of ESP32 to other side of pipe. This is how capacity levels can be checked in containers of chemicals that can destroy the metal wire so can be placed outside the container. Worth a try. If you find a big enough capacitance between flowing and non flowing water then take it out of test mode and use the valve you see in esp32 logs to set binary of flow and not flowing water. Check it out in ESPhome documentation.