Make a sonoff have a heartbeat with tasmota

Does anyone have idea’s of how to make a sonoff have a heartbeat? I want to make a couple of wireless motion detectors with a sonoff that plug directly into the wall. I have all the equipment but before I start I want to find a way to determine if someone unplugs my wireless motion detector. My first idea is to attach a wall wart and a relay which a sonoff can monitor if it loses power and opens. That is a lot of extra bulk so I thought there might be an easier software method.

maybe create a binary sensor and an automation to send a notification when a device is offline.

binary_sensor:
  - platform: mqtt
    name: "mydevicex01"
    state_topic: "tele/mydevicex01/LWT"
    value_template: "{{ value }}"
    payload_on: "Online"
    payload_off: "Offline"
    device_class: connectivity

Don’t hold me to this because I haven’t tried it yet.

I believe that under Tasmota you can set up a repeating timer that could send a MQTT message say once a minute. On the HA side create an automation that triggers if it doesn’t see the message come in say every 2 minutes (or some time frame that is slightly longer than what Tasmota sends).

If the Tasmota is unplugged it may not send an offline message. You might be able to watch the WiFi connection.

1 Like

Thanks, the exact simply answer I was looking for using scan interval.