New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature "dynamic topic targets" #169

Merged
merged 2 commits into from Feb 16, 2016

Conversation

Projects
None yet
3 participants
@amotl
Collaborator

amotl commented Feb 14, 2016

Dear Jan-Piet and Ben,

first things first: Thanks for sharing this great project!

We tried to enhance mqttwarn to add functionality we need for our Hiveeyes bee monitoring project. The feature was implemented as generic as possible to provide added value to the mqttwarn infrastructure in general. Kudos go to @einsiedlerkrebs for conceiving it and making this possible.

A short overview over the changes made:

  • Interpolate transformation data into topic targets
  • Improve overall robustness and address #27, this was essential for implementing the feature

Please get back to us if you have further questions or suggestions.

With kind regards,
Andreas.

Add feature "dynamic topic targets"
- Interpolate transformation data values into topic targets
- Improve overall robustness and address #27
@einsiedlerkrebs

This comment has been minimized.

einsiedlerkrebs commented Feb 14, 2016

We also updated the appropriate Wiki page. Unfortunately GitHub can not issue pull requests to Wikis, so we link to a PR issued to a clone: hiveeyes/mqttwarn-wiki#1

Cheers,
Richar

@jpmens

This comment has been minimized.

Owner

jpmens commented Feb 15, 2016

This basically looks very good, however it crashes mqttwarn if I publish a non-JSON payload to your example.

2016-02-15 11:50:49,750 DEBUG [mqttwarn] Section [topic-targets-dynamic] matches message on test/topic-targets-dynamic. Processing...
2016-02-15 11:50:49,750 WARNING [mqttwarn] Cannot decode JSON object, payload=blub: No JSON object could be decoded
Traceback (most recent call last):
  File "./mqttwarn.py", line 970, in <module>
    connect()
  File "./mqttwarn.py", line 930, in connect
    mqttc.loop_forever()
  File "/usr/local/lib/python2.7/site-packages/paho/mqtt/client.py", line 1212, in loop_forever
    rc = self.loop(timeout, max_packets)
  File "/usr/local/lib/python2.7/site-packages/paho/mqtt/client.py", line 792, in loop
    rc = self.loop_read(max_packets)
  File "/usr/local/lib/python2.7/site-packages/paho/mqtt/client.py", line 1043, in loop_read
    rc = self._packet_read()
  File "/usr/local/lib/python2.7/site-packages/paho/mqtt/client.py", line 1425, in _packet_read
    rc = self._packet_handle()
  File "/usr/local/lib/python2.7/site-packages/paho/mqtt/client.py", line 1881, in _packet_handle
    return self._handle_publish()
  File "/usr/local/lib/python2.7/site-packages/paho/mqtt/client.py", line 2009, in _handle_publish
    self._handle_on_message(message)
  File "/usr/local/lib/python2.7/site-packages/paho/mqtt/client.py", line 2165, in _handle_on_message
    self.on_message(self, self._userdata, message)
  File "./mqttwarn.py", line 532, in on_message
    send_to_targets(section, topic, payload)
  File "./mqttwarn.py", line 586, in send_to_targets
    targetlist = [t.format(**data) for t in targetlist]
KeyError: u'loglevel'

Could you address that please?

@jpmens

This comment has been minimized.

Owner

jpmens commented Feb 15, 2016

@einsiedlerkrebs Thanks for the documentation which I have "merged" ;-)

@amotl

This comment has been minimized.

Collaborator

amotl commented Feb 15, 2016

Sorry for missing that detail, would have been easy to catch, but it was late. :-) Will have a look and send a fix tonight.

@jpmens jpmens merged commit 4170e52 into jpmens:master Feb 16, 2016

@jpmens

This comment has been minimized.

Owner

jpmens commented Feb 16, 2016

Nur Döner macht schöner! Merged, Danke!

@amotl amotl deleted the hiveeyes:wip/topic-targets-dynamic branch Feb 16, 2016

@amotl

This comment has been minimized.

Collaborator

amotl commented Feb 16, 2016

Thanks a bunch!

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