My waterleak alert setup

I think I got it very good by now, so I just wanted to share with you all.
Thanks to our great community I think I got all the kinks out of it.

So it is based on RF433 sensors that only has 1 code to transmit (wet)

So the RFBridge sends the code as mqtt, and that is picked up by an automation that decrypts it, and makes a new MQTT message.

So first of I have set up this card:

card:
  color: 'rgb(0,100,255)'
  color_type: icon
  entity_id: binary_sensor.waterleak_bathroom
  icon: 'mdi:water'
  name: Oversvømmelse i badeværelse
  tap_action:
    action: call-service
    service: script.resetwaterleakbath
  type: 'custom:button-card'
conditions:
 - entity: binary_sensor.waterleak_bathroom
   state: 'on'
type: conditional

Then I have an automation to send out the alert to our cellphones with an action button in it:

- id: '1577440436953'
  alias: Alert - Waterleak bathroom alert
  description: Sends out to cell phones if there is a waterleak
  trigger:
  - entity_id: binary_sensor.waterleak_bathroom
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      data:
        actions:
        - action: resetleakbath
          title: Nulstil alarm
        priority: high
        tag: waterleakbathalert
        url: https://myurl.ui.nabu.casa/lovelace/0
      message: Oversvømmelse i badeværelse!
      title: ALARM!
    service: notify.webpush

Then I’ve made a script to match the action button:

- id: '1577522444850'
  alias: Alert - reset waterleak bath - button pressed
  description: ''
  trigger:
  - event_data:
      action: resetleakbath
    event_type: html5_notification.clicked
    platform: event
  condition: []
  action:
  - service: script.resetwaterleakbath

The card and the action calls this script:

resetwaterleakbath:
  alias: "Fjerner alarm pĂĄ lovelace og html5 webpush"
  sequence:
    - service: html5.dismiss
      data:
        data:
          tag: waterleakbathalert
    - service: mqtt.publish
      data:
        payload: '{"RfReceived":{"Sync":10140,"Low":320,"High":920,"Data":"33C112OFF","RfKey":"None"}}'
        qos: 1
        retain: false
        topic: 'tele/rfbridge/RESULT'

The script sends the code that corresponds to the off setting for the waterleak, which is interpreted by the mqtt automation, and it also removes the notification from the html5, so others don’t see if you’ve solved the problem.

3 Likes

Nice work! I really like the part with stopping notifications if someone else have solved/saw the problem. Thanks a lot didn’t think of that myself. :slight_smile:

1 Like