Temperature sensor on pipe to monitor shower use

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.

You could create a ESPHome delta sensor, then look for when temperature turns.

Then maybe create a binary sensor or two as helpers.

You’ll need to join the ESPHOME Discord for that link.

Can you please provide a link for this kind of sensor? Maybe you have an example of implementation as well ?

Would you please share an example ?

It’s in the link…!

https://community.home-assistant.io/t/invitation-project-suggestion-an-automated-potted-plant/431846/119

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.

1 Like

If you are talking about your discord link, it leads to nothing (and I am a member of the esphome discord).

Right… Hmm…

Well I used the “copy link to message” Discord feature and just double checked it is correct. So not sure how else to do it.

Seems to work for me.

Searching Discord for “Delta sensor” will also bring it up…

I have manage to solve my problem with a helper and two automations.
First of all I create a input_number sensor.

{{ states('input_number.attic_shower_max_temperature') }}

When temperature is rising the following automation is running, sets the bathroom sensor to occupied, plays a TTS notification and some bathrooom music with Alexa.

alias: Bathroom is occupied (ON)
description: When pipe's temperature above 25°C turn on occupancy switch
trigger:
  - platform: numeric_state
    entity_id: sensor.attic_hot_water_pipe
    above: 25
condition:
  - condition: state
    entity_id: input_boolean.attic_shower_is_occupied
    state: "off"
action:
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.attic_shower_is_occupied
  - service: persistent_notification.create
    data:
      title: INFORMATION
      message: |
        Someone has just started to have a shower at {{ states('sensor.time') }}.
  - service: notify.mobile_app_sm_g980f
    data:
      title: INFORMATION
      message: Someone is having a shower...
  - if:
      - condition: state
        entity_id: group.attic_wc
        state: "on"
    then:
      - service: media_player.volume_set
        data:
          volume_level: 1
        target:
          entity_id: media_player.bathroom
      - service: notify.alexa_media
        data:
          target:
            - media_player.bathroom
          data:
            type: tts
          message: >-
            Hmmm. I am sensing that someone is having a shower...Here are some
            songs to sing in the shower!
        alias: "Notifications: Send a notification with alexa_media (bathroom)"
      - delay:
          hours: 0
          minutes: 0
          seconds: 5
          milliseconds: 0
      - service: media_player.select_source
        data:
          source: Bathroom
        target:
          entity_id: media_player.spotify_makis_solomos
      - service: media_player.shuffle_set
        data:
          shuffle: true
        target:
          entity_id: media_player.bathroom
      - service: media_player.play_media
        data:
          media_content_type: playlist
          media_content_id: >-
            https://open.spotify.com/playlist/37i9dQZF1DWSqmBTGDYngZ?si=d31f0e30a8f14ede
        target:
          entity_id: media_player.spotify_makis_solomos
mode: single

At the same time, another automation is running which saves pipe’s temperature to the helper.

alias: Bathroom is occupied save temperature to helper
description: ""
trigger:
  - platform: template
    value_template: >-
      {{ states('sensor.attic_hot_water_pipe') >
      states('input_number.attic_shower_max_temperature')  }}
condition: []
action:
  - service: input_number.set_value
    data:
      value: "{{ states('sensor.attic_hot_water_pipe') }}"
    target:
      entity_id: input_number.attic_shower_max_temperature
mode: single

Finally, a final automation checks the temperature and if is falling it consider that the shower is completed:

alias: Bathroom is occupied (OFF)
description: ""
trigger:
  - platform: time_pattern
    minutes: /15
condition:
  - condition: state
    entity_id: input_boolean.attic_shower_is_occupied
    state: "on"
  - condition: template
    value_template: >-
      {{ ((states('sensor.attic_hot_water_pipe') | float -
      states('input_number.attic_shower_max_temperature') | float) *-1) > 3  }}
action:
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id: input_boolean.attic_shower_is_occupied
  - service: persistent_notification.create
    data:
      message: |
        Shower is completed {{ states('sensor.time') }}.
      title: INFORMATION
  - service: media_player.media_stop
    data: {}
    target:
      entity_id: media_player.bathroom
mode: single

It works flawlessly!!!

(please note that I had to reset the max. temperature helper so it will run again next day)

alias: Bathroom is occupied reset max. temperature
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.attic_hot_water_pipe
    below: 20
condition:
  - condition: state
    entity_id: input_boolean.attic_shower_is_occupied
    state: "off"
action:
  - service: input_number.set_value
    data:
      value: 21
    target:
      entity_id: input_number.attic_shower_max_temperature
mode: single

1 Like

Why isn’t this the trigger?
If this is the trigger then it will trigger immediately as the temperature drops when shower is occupied, not sure I understand why you need to wait for 15 minutes

Because using a numeric state trigger doesn’t work always.
If it pass through the threshold it won’t trigger untill it goes up and down again…

I agree that this is the right trigger to fire but I couldn’t make it to work.
It didn’t fire always with (pipe’s temperature - max. temperature) < 3

And If I change the row of sensors e.g. (max - pipe) will also trigger when temperature rises … ** see above automation. (because it will give a negative number which is < 3)

So it will switch off the occupancy sensor before it starts …

Hope I can make myself clear here …

But why don’t you replicate it? …See yourself the barries that make me choose the time patern trigger instead.

No… as a template trigger, just as your condition.
I have several template triggers not specifically like this but they all work fine.

Hi,
I think I would not stick to these static temperature values. I think a more universal way would be (I believe @Mahko_Mahko mentioned that) to just use the temperature gradient / difference over time.
Of course it depends on how you define the window size for your samples.

But the idea is:

  • any temperature rise (no matter which the “starting temperature” was) will indicate that someone is showering (or anything else that uses warm water).
  • any temperature drop indicates, that warm water usage has been stopped.

So the logic would be (pseudocode):

delta_T = new_sample - old_sample
if delta_T > threshold1: warm_water_use = true
else if delta_T < threshold2: warm_water_use = false

And because someone might take a break while showering (maybe because his/her hair conditioner needs some time) your automation trigger to determine if the shower is really in use or not could observe the duration of how long warm_water_use is true or false.
Something like:

if warm_water_use is true for > delay1: shower_occupied = true
else if warm_water_use is false for > delay2: shower_occupied = false

You only have to define (or evaluate) a reasonable sampling time, the thresholds to determine if warm water is used or not, and the delays to say if the shower is really occupied or not.

This would be universal and flexible.

Greetings!

This is exactly what I suggested in post 7. Use derivative, trend or statistics sensor to know where the data is heading.
But by some reason he uses input number and automations. :man_shrugging:

Sry, I have missed that one :sweat_smile: !
But nice to know that we share a basically same idea :slight_smile: .

Can we please have some real code for ESP ???

because maybe HE is not that expert user like you … :slight_smile:
and maybe YOU should read more carefully. :wink:
Please read my post #13
Trend and derivative sensors didn’t work for me .

The only thing you said was:

I didn’t reply to it before since it looked like an excuse.

1 If your sensor is ESP based then set the update interval.
2 if the sensor does not update frequently enough for a derivative sensor then why would work creating a manual derivative sensor?
3 if your automation triggers every 15 minutes then how can speed be an issue at all?
4 your automation:

alias: Bathroom is occupied save temperature to helper
description: ""
trigger:
  - platform: template
    value_template: >-
      {{ states('sensor.attic_hot_water_pipe') >
      states('input_number.attic_shower_max_temperature')  }}
condition: []
action:
  - service: input_number.set_value
    data:
      value: "{{ states('sensor.attic_hot_water_pipe') }}"
    target:
      entity_id: input_number.attic_shower_max_temperature
mode: single

Triggers in the exact same rate as a derivative, trend or statistics sensor because it’s based on the same sensor updating.

Not sure exactly how these sensors did not work for you since they are based on the same entity.
The only difference is that my suggestion was to trigger on a drop in this sensor of a certain degree. I can’t answer on what that degree is because I don’t have something similar.

My answer on you suggestion was:

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 derivative sensors but not always accurate in my situation.

I have never talked about a humidity sensor.