How do I use a template sensor to count # of people taking shower today?

There are a bunch of ways to accomplish this…

Make a template binary sensor off the two humidity sensors, to know when “someone” is showering; then use a History Stats sensor to count the “on” states. Concurrent showers in the two room might be an issue…

Or, you could use a combination of template binary sensors and a trigger-based template sensor.

template:
  - binary_sensor:
      - name: Shower active Bathroom 1
        state: "{{ states('sensor.bathroom_1_humidty')|float(0) > 65 }}"
        delay_off: "00:05:00"
      - name: Shower active Bathroom 2
        state: "{{ states('sensor.bathroom_2_humidty')|float(0) > 65 }}"
        delay_off: "00:05:00"

  - triggers:
      - trigger: state
        to: 'on'
        from: 'off'
        entity_id:
          - binary_sensor.shower_active_bathroom_1
          - binary_sensor.shower_active_bathroom_2
      - id: reset
        trigger: time
        at: "00:00:01"
    sensor:
      - name: Daily Shower count
        state: |
          {% set current = (this.state or 0)|int(0) %}
          {{ 0 if trigger.id == 'reset' else current + 1 }}

Alternatives to consider:

MeasureIt custom integration

Maybe Wash Data could be leveraged to handle it…? That’s probably overkill, but it might make it easier to get an accurate count of concurrent showers.

1 Like