Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[mosquitto-dev] mqttwarn filter

I could not find a better place to ask my question ... Hope you don't mind me here.
I am trying to use mqttwarn with owntracks to generate an alert when I 
leave work, so I can send my wife a message. So I have created an entry 
in the mqttwarn.ini like so:
[owntracks/egraaf/werkfoon]
targets = log:info, pushover:wife
filter = OwntracksFilter()
datamap = OwnTracksTopic2Data()
format = {username}: {event} => {desc}

The datamap is from the mqttwarn README example, and it works fine. The filter is something I cobbled together:
def OwntracksFilter(topic, message):
    data = dict(json.loads(message).items())
    if data['desc'] == "Work" and data['event'] == "leave":
        return False
    return True

The filter raises a Python exception, and I don't know why
In the mqttwarn log:
Cannot invoke filter function OwntracksFilter defined in owntracks/egraaf/werkfoon: 'desc'
I have no experience with Python, so I am probably missing something 
simple, but I would love some help here. The Python file with my own 
functions loads fine, and I can call the filter function with a json 
formatted message without errors.





Back to the top