Disable update interval and only update sensor when required?

I am trying to save energy on a battery powered water level sensor.

GPIO32 provides 3.3V to the sensor when I want to take a reading.

GPIO35 will read the voltage of the water level sensor however it will still report small voltage even if the level sensor is not powered up.

Is there a way I can disable regular updates of GPIO35 unless I specifically want to? At the moment I’m trying to do it by turning GPIO32 on and then trying to update the sensor but I’m just making up syntax now because it doesn’t work :slight_smile:

Maybe someone has some other ideas to achieve this?

output:

  • platform: gpio
    pin: GPIO32
    id: jumper_control

switch:

  • platform: output
    name: “${device_name} Jumper Control”
    output: jumper_control
    on_turn_on:

    • delay: 500ms # Adjust delay as needed for sensor stabilization
    • sensor.update: pressure_volts
    • delay: 5s # Delay before turning off the switch
    • output.turn_off: jumper_control
  • platform: adc
    pin: GPIO35
    name: “${device_name} Pressure Sensor Volts”
    id: pressure_volts
    accuracy_decimals: 2
    device_class: voltage
    unit_of_measurement: “V”
    ##Removed update_interval to rely on manual updates

Okay adding a filter with some lambda to return a NULL value when power is not being supplied to the sensor seems to have done the trick!

  - platform: adc
    pin: GPIO35
    name: "${device_name} Pressure Sensor Volts"
    id: pressure_volts
    accuracy_decimals: 2
    device_class: voltage
    unit_of_measurement: "V"
    update_interval: 10s
    filters:
      - lambda: |-
          if (id(jumper_control_switch).state) {
            return x;
          } else {
            return {};  // Skip update when switch is off
          }
1 Like