Hermes or paho.mqtt?


To program actions in python, is it better to use the module or paho.mqtt.client and paho.mqtt.publish.
it gives a rather different writing, and beginner sided in python I ask myself the question before going into a more important programming in size ???
Thank you for your answers


I have used both methods. If you use MQTT directly, it’s more low-level, so you would have to code a lot of things yourself, but it’s doable. In general, I would use the Hermes Python method unless you want to do some low-level stuff that isn’t possible with it.


Hermes is not using the data from snips.toml if I’m right?

I’m thinking about rewriting my apps to read the snips.toml for the data and using paho.mqtt (somebody commented on one of my apps, that it is not working with his pw settings - I got to do something ;))


I have been thinking the same. I have actually started to write some helper code that reads the MQTT connection settings from /etc/snips.toml and connects with paho.mqtt, but that only works for the complete MQTT connection settings when you use paho.mqtt directly, not when using Hermes Python, right?


I’m starting to understand better the difference


Just a quick snippet for reading the data from the toml:

    with open("/etc/snips.toml") as toml_file:
        snips_toml = toml.load(toml_file)
    if 'snips-common' in snips_toml:
        if 'mqtt_username' in snips_toml['snips-common'] and 'mqtt_password' in snips_toml['snips-common']:
            self.client.username_pw_set(snips_toml['snips-common']['mqtt_username'], snips_toml['snips-common']['mqtt_password'])
        if 'mqtt' in snips_toml['snips-common']:
            MQTT_HOST, port = snips_toml['snips-common']['mqtt'].split(':')
            MQTT_PORT = int(port)
    self.client.connect(MQTT_HOST, MQTT_PORT, 60)


I’m doing the same in the code I wrote, but Hermes doesn’t support authentication nor TLS, if I remember correctly.