Water filter quality and water softener status

@carpenike, I had created this thread to understand better how to get two readings at the same time from a single trigger and I’ve implemented it and been using it for a long time. It works very well and that way I am comparing pressure sensor values that are much closer to being measured at the same time. It’s a bit confusing but if you look at how the update_interval, on_raw_value, and on_value keys look you can figure out how it’s working:

sensor:
  - platform: ads1115
    multiplexer: 'A0_GND'
    gain: 6.144
    id: incoming_water_pressure_raw
    update_interval: never
    accuracy_decimals: 1
    internal: True
    filters:
      - calibrate_polynomial:
          degree: 4
          datapoints:
            - 0.455 -> 0.0  
            - 0.722 -> 10.0
            - 0.824 -> 15.0
            - 0.948 -> 20.0
            - 1.061 -> 25.0
            - 1.178 -> 30.0
            - 1.280 -> 35.0
            - 1.398 -> 40.0
            - 1.501 -> 45.0
            - 1.622 -> 50.0
            - 1.738 -> 55.0
            - 1.859 -> 60.0
            - 1.977 -> 65.0
            - 2.097 -> 70.0
            - 2.209 -> 75.0
  - platform: ads1115
    multiplexer: 'A1_GND'
    gain: 6.144
    id: outgoing_water_pressure_raw
    update_interval: 1s
    accuracy_decimals: 1
    internal: True
    on_value:
      then:
        - component.update: incoming_water_pressure_raw
        - component.update: delta_water_pressure
    filters:
      - calibrate_polynomial:
          degree: 4
          datapoints:
            - 0.539 -> 0.0
            - 0.775 -> 10.0
            - 0.854 -> 15.0
            - 0.963 -> 20.0
            - 1.051 -> 25.0
            - 1.148 -> 30.0
            - 1.232 -> 35.0
            - 1.348 -> 40.0
            - 1.432 -> 45.0
            - 1.530 -> 50.0
            - 1.637 -> 55.0
            - 1.743 -> 60.0
            - 1.854 -> 65.0
            - 1.971 -> 70.0
            - 2.078 -> 75.0
  - platform: template
    name: "Delta Water Pressure"
    id: delta_water_pressure
    update_interval: never
    unit_of_measurement: "psi"
    icon: "mdi:kettle-alert"
    accuracy_decimals: 1
    lambda: |-
      return (id(incoming_water_pressure_raw).state - id(outgoing_water_pressure_raw).state);
    on_raw_value:
      if:
        condition:
          sensor.in_range:
            id: delta_water_pressure
            above: 1.0
        then:
          - lambda: |-
              id(delta_water_pressure).publish_state(x);
    on_value:
      then:
        - component.update: incoming_water_pressure
        - component.update: outgoing_water_pressure
    filters:
      - throttle: 10s
      - or:
        - heartbeat: 300s
        - delta: 0.5
  - platform: template
    name: "Incoming Water Pressure"
    id: incoming_water_pressure
    update_interval: never
    unit_of_measurement: "psi"
    icon: "mdi:gauge"
    accuracy_decimals: 1
    lambda: |-
      return id(incoming_water_pressure_raw).state;
  - platform: template
    name: "Outgoing Water Pressure"
    id: outgoing_water_pressure
    update_interval: never
    unit_of_measurement: "psi"
    icon: "mdi:gauge-low"
    accuracy_decimals: 1
    lambda: |-
      return id(outgoing_water_pressure_raw).state;
  - platform: hx711
    dout_pin: D0
    clk_pin: D1
    gain: 128
    name: "Salt Bin Weight"
    update_interval: 10s
    unit_of_measurement: lbs 
    icon: "mdi:shaker"
    accuracy_decimals: 1
    filters:
      - median:
          window_size: 61
          send_every: 60
          send_first_at: 6
      - lambda: return x * -0.0000911 + 23.3;

Every second the internal outgoing “raw” sensor is measured and that triggers an update of the internal incoming “raw” and delta sensor values. The delta sensor in turn updates the published outgoing and internal values that make their way to home assistant.

I have been toying with a couple of ideas that I haven’t acted on but may in the future:

  1. Installing a flow meter so I can use it to trigger updates and get water throughput. I haven’t done this yet because I’m worried about impacting the total throughput of the system and many of the flow meters are designed for non-potable water systems.
  2. Installing a pressure regulator after the filter system and post pressure sensor and installing a third pressure sensor after the pressure regulator. My water pressure fluctuates quite a bit on the supply 50-75psi, so I’m tempted to try to level it out but again I don’t really want to impact the throughput and I don’t know how much it would be impacted by installing a pressure regulator.

If I do eventually do one or both of these things, it’ll likely be mostly for the data collection aspects. :slight_smile: