Flood Alarm Reset for IKEA BADRING with ZHA 🚱

While IKEA BADRING reliably report when they are wet, the message that they are dry often does not reach Home Assistant.
This automation blueprint works for ZHA users and requires zha_toolkit (avalible in HACS) to poll for updates when BADRING reports wet.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

edit: I tested this several times before posting and it worked great with no retries, same poll frequency. Now however the polling is timing out even with retries.
edit2: Added more retries and it’s working

blueprint:
  name: Flood Alarm Reset
  description: |-
    While [IKEA BADRING](https://csa-iot.org/csa_product/badring-water-leakage-sensor/) reliably report when they are wet, the message that they are dry often does not reach Home Assistant.
    This automation blueprint works for [ZHA](https://www.home-assistant.io/integrations/zha) users and **requires** [zha_toolkit](https://github.com/mdeweerd/zha-toolkit) (avalible in HACS) to poll for updates when BADRING reports wet.
  domain: automation
  input:
    flood_sensor:
      name: Flood Sensor
      selector:
        entity:
          filter:
            - domain: binary_sensor
              device_class: moisture
    frequency:
      name: poll Frequency
      default:
        minutes: 1
      selector:
        duration:

triggers:
  - trigger: state
    entity_id: !input flood_sensor
    to: "on"
  - # Account for if sensor was reporting wet before Home Assistant started
    platform: homeassistant
    event: start

mode: restart

actions:
  - delay: !input frequency
  - repeat:
      while:
        - condition: state
          entity_id: !input flood_sensor
          state: "on"
      sequence:
        - action: zha_toolkit.attr_read
          data:
            ieee: !input flood_sensor
            cluster: 1280
            attribute: 2
            use_cache: false
            tries: 50
        - delay: !input frequency