Skip to content

Instantly share code, notes, and snippets.

@matbor
Last active August 29, 2015 13:57
Show Gist options
  • Save matbor/9657897 to your computer and use it in GitHub Desktop.
Save matbor/9657897 to your computer and use it in GitHub Desktop.
Last Will and Testament Notification Function for mqttwarn. https://github.com/jpmens/mqttwarn

note; I have all my scripts setup so that the lwt (last will and testament) publishes 'offline' if the scripts die.

################################################################
##### Last Will and Testament Notification Function #####
################################################################
#lwt offline message to check for
lwtmsg_offline = 'offline'
#last will and Testaments topics to not suppress
lwttopics2mon = [
'/lwt/testing1', #testing topic
]
#filter to check to see if the device/software is offline
def lwtfilter(topic, message):
for t in lwttopics2mon:
if t in topic:
if message == lwtmsg_offline:
return False #dont suppress the notifcations
return True #suppress the notification
[lwt]
topic = /lwt/#
targets = log:info,pushover:software
filter = lwtfilter()
format = Device: {topic} went ==> {payload} @{_dthhmm}
title = MQTT LWT Notification
@sumnerboy12
Copy link

Just added a change to allow you to specify the lwt payload in mqttwarn.

mqtt-tools/mqttwarn@1c24e6a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment