Alert if MQTT entity stops sending messages

I want to be able to detect if an MQTT module has stopped sending. Each module send an RSSI value every 30 seconds and I’m wondering if there is an easy way to detect the loss of that message. A typical entity would be sensor.hall_rssi

I’m a complete idiot when it comes to HA so please provide as much info as you can.

I want to send an alert via Telegram. I already send Telegram messages for other conditions.

Not sure this is the best way, but for a few of my devices, I built an automation to check them every 10 minutes:

  - alias: Power Meter Offline
    initial_state: True
    trigger:
      platform: time_pattern
      minutes: '/10'
    condition: "{{ (as_timestamp(now()) - as_timestamp(states.sensor.power_meter.last_updated)) > 900 }}"
    action:   
      - service: notify.email
        data:
          message: Power Meter hasn't updated in over 15 minutes!
      - service: notify.telegram
        data_template:
          message: "Power Meter hasn't updated in over 15 minutes!"
          data:
            inline_keyboard:
            - 'Turn off:/turnoffpowermeteralarm, Leave it:/donothing'

The associated turn off automation looks like this:

  - alias: Telegram - Turn Off Power Meter Offline Notification
    trigger:
      platform: event
      event_type: telegram_callback
      event_data:
        command: '/turnoffpowermeterofflinealarm'
    action:
    - service: automation.turn_off
      entity_id: automation.power_meter_offline
    - service: notify.telegram
      data:
        message: >
          Power Meter Offline Notification turned off

I have similar automation that runs every hour and checks to make sure all my zwave sensors have reported in the last 13 hours.

Thanks. I will give that a try.

I had tried this and thought it wasn’t working, but it now appears that there are periods where the MQTT connection fails. I’m now off on another investigation trying to sort that out.!!

  • id: ‘1234567890123’
    alias: Notify on Kitchen_cam Inactivity
    description: Sends a Telegram message if the MQTT module stops sending messages.
    trigger:
    • platform: state
      entity_id: sensor.kitchen_rssi
      for: “00:10:00” # 10 minute
      condition:
      action:
      • service: notify.gajjer
        data:
        message: “Alert: Kitchen Cam has stopped”