Button (or service) to force state of a sensor?

Hi, I have a Zigbee water leak sensor that takes time to set itself back to “no leak detected” state. I use it to monitor an AC drainage canister and have a big red conditional banner on top of my dashboard when it’s full. Leak detection is fine, No Leak takes time, and it’s annoying.

What I want is to tap this banner to set the sensor to “no leak” (obviously after I empty the can) and the banner to disappear.

I haven’t found a way to do this. Any tips? Thanks!

Don’t try to set a sensor state. Instead, set up a trigger-based template binary sensor as below: adjust for your sensor and button entities and states, then use that to trigger the banner. I’ve used device_class: moisture as the closest in the list.

template:
  - trigger:
      - platform: state
        entity_id: input_button.leak_reset
      - platform: state
        entity_id: binary_sensor.leak_detector
    binary_sensor:
      - name: Filtered leak detector
        state: "{{ 'off' if 'button' in trigger.entity_id else trigger.to_state.state }}"
        device_class: moisture

Thanks, will try :slight_smile:

It’ll need to go into your configuration.yaml or templates.yaml depending how your config is set up. You can’t do this via the UI (yet)…

1 Like

Right. I started in 2019 so I’m quite used to yaml. Thanks!

1 Like