{"action":"created","issue":{"url":"https://api.github.com/repos/jpmens/mqttwarn/issues/17","labels_url":"https://api.github.com/repos/jpmens/mqttwarn/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/jpmens/mqttwarn/issues/17/comments","events_url":"https://api.github.com/repos/jpmens/mqttwarn/issues/17/events","html_url":"https://github.com/jpmens/mqttwarn/issues/17","id":27757210,"number":17,"title":"deal with out of control publishing","user":{"login":"matbor","id":1978503,"avatar_url":"https://avatars.githubusercontent.com/u/1978503?v=3","gravatar_id":"","url":"https://api.github.com/users/matbor","html_url":"https://github.com/matbor","followers_url":"https://api.github.com/users/matbor/followers","following_url":"https://api.github.com/users/matbor/following{/other_user}","gists_url":"https://api.github.com/users/matbor/gists{/gist_id}","starred_url":"https://api.github.com/users/matbor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matbor/subscriptions","organizations_url":"https://api.github.com/users/matbor/orgs","repos_url":"https://api.github.com/users/matbor/repos","events_url":"https://api.github.com/users/matbor/events{/privacy}","received_events_url":"https://api.github.com/users/matbor/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-02-17T23:45:07Z","updated_at":"2015-12-18T12:00:11Z","closed_at":null,"body":"Maybe add a feature that if _x_ amount of the same messages is published within _y_ amount of time, then just send one message saying that.  Instead of publishing all the messages, then goto sleep on that message for _z_ time.  \r\n\r\nAs you could easily blow api limits on some services, or it just becomes annoying on your mobile device!"},"comment":{"url":"https://api.github.com/repos/jpmens/mqttwarn/issues/comments/165763664","html_url":"https://github.com/jpmens/mqttwarn/issues/17#issuecomment-165763664","issue_url":"https://api.github.com/repos/jpmens/mqttwarn/issues/17","id":165763664,"user":{"login":"appsxt","id":5492165,"avatar_url":"https://avatars.githubusercontent.com/u/5492165?v=3","gravatar_id":"","url":"https://api.github.com/users/appsxt","html_url":"https://github.com/appsxt","followers_url":"https://api.github.com/users/appsxt/followers","following_url":"https://api.github.com/users/appsxt/following{/other_user}","gists_url":"https://api.github.com/users/appsxt/gists{/gist_id}","starred_url":"https://api.github.com/users/appsxt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/appsxt/subscriptions","organizations_url":"https://api.github.com/users/appsxt/orgs","repos_url":"https://api.github.com/users/appsxt/repos","events_url":"https://api.github.com/users/appsxt/events{/privacy}","received_events_url":"https://api.github.com/users/appsxt/received_events","type":"User","site_admin":false},"created_at":"2015-12-18T12:00:11Z","updated_at":"2015-12-18T12:00:11Z","body":"Hi,\r\n\r\nThanks for sharing such an excellent project.\r\n\r\nI too was wondering if there is an easy way to limit the number of repeat warnings. Consider a sensor publishing temperature readings once a minute and we're interested in receiving high temperature alarms above 50 degrees Celsius. The high temperature condition may not be resolved instantly and we don't need 60 notifications per hour.\r\n\r\nI was able to limit publication with `datetime` in a custom filter, to in this instance only publish every 5 minutes.\r\n\r\n```python\r\nimport datetime\r\ndef highTemperatureAlarm(topic,message):\r\n        try:\r\n                float(message)\r\n                if datetime.datetime.now().minute % 5 == 0:\r\n                        return float(message) < 50.0\r\n                else:\r\n                        return True\r\n        except:\r\n                return True\r\n```\r\n\r\nThis however may miss some alarms altogether. Is it possible to code something like the typical Arduino `millis()` check?\r\n\r\n```c\r\n#define alarmDelay 300\r\n...\r\nint lastAlarm = 0;\r\n...\r\nif(millis() - lastAlarm > alarmDelay) {\r\n\tlastAlarm = millis();\r\n\t// Publish alarm\r\n} else {\r\n\t// Don't publish alarm\r\n}\r\n```\r\n\r\nI guess that would require some kind of global variable declaration. I haven't tried this yet in Python (I'm actually quite new to Python) or mqttwarn.\r\n\r\nCheers,\r\n\r\nMick"}}