Hermes: Send messages to customer specific topics


#1

It would be nice if you were able to send MQTT messages with any topic from the apps, without creating an own connection to your MQTT broker.

I know a second connection is not a problem, but I guess it would make some things way more accessible and fast in development.

something like:
hermes.send(topic=‘hermes/display/siteID’, payload=‘my custom message payload’)
or
hermes.send(topic=‘cmnd/sonoff/kitchen/POWER’, payload=‘ON’)

Thank you!

(i can’t create my own tag ‘hermes’?)


#2

You can, nothing prevents you to send mqtt messages wherever you want


#3

well, then I should update my feature request to include a complete documentation:
https://snips.gitbook.io/documentation/console/actions/code-your-action/hermes-python

No matter how hard I look, i can only find:
.publish_continue_session
.publish_end_session
.publish_start_session_action
.publish_start_session_notification
.start
.subscribe_intent
.subscribe_intents
.subscribe_session_ended
.subscribe_session_queued
.subscribe_session_started

A look into hermes.py reveals nothing else.

So to directly answer to your comment: If there really is a way to use the build in hermes class to send a message, the only thing that prevents me from using it, is your precise answer…


#4

I’m using my own channels to query data from my satellites, like temperature, Co2 etc etc etc

	def getSensorReadings(self):
	    self.notifyAllModules('projectAlice/modules/alice/getSensors', siteId='all')

    ................................

	def sendToModule(self, ip, topic, payload=None):
	    if payload is None:
		    payload = {}

	    try:
		    publish.single(topic, payload=json.dumps(payload), hostname=ip, port=1883)
    ....................................

So you can publish whatever you want wherever you want


#5

thank you!

I’m actually doing exactly the same with publish.single from paho.
I was just hoping for a direct function in the existing hermes instance so I don’t have to bother with ports/ip anymore

So I guess I’ll stay with that solution for now, and this thread will remain as a suggestion for the devs


#6

This is a nice idea and I need something like this. The great thing is it would even be possible to call this from the Snips console because the Hermes object is accessible to the console.


#7

this is something i have asked before and also have added in the forums too as a feature request
the hermes python lib should allow access to the mqtt client so we can link into that without having to create yet another mqtt connection

I use publish.single too but if the user uses a username/pwd or certificate then that’s more coding me for to have to ask the user to once again enter it in


#8

not the point of the post… Hermes does not just allow users access to send mqtt messages wherever they want


#9

hermes doesn’t use password/username/certificate at the moment! You have to use paho already if you want to enable it. I did it for one of my apps already by reading the /etc/snips.toml - but you lose the intentMessage Objekt…
You can have a look at “Garuda” the indian messenger god here: