Feature description
Following our discussion here
A scene must be able to be triggered when an MQTT message arrives on a particular topic.
Feature description
Following our discussion here
A scene must be able to be triggered when an MQTT message arrives on a particular topic.
And that would be useful in other cases, I think!
I need to
I made a small suggestion on this PR :
I didnât add a new trigger. I just added the ability to launch any scene from an MQTT message.
To do this you need to publish a « START » message to the channel: « gladys/scene/[sceneSelector] »
What do you think?
@Lokkye just one word: Awesome! ![]()
For that you need to publish a « START » message in the channel: « gladys/scene/[sceneSelector] »
Youâll need to explain because I donât see the « how »?
Otherwise itâs great for opening scenes from outside via MQTT or Node-RED!
Well done on these developments!!!
![]()
Super cool @Lokkye!
For the topic format, we need to keep the format we currently have on the other MQTT topics, notably the « master » prefix which indicates weâre addressing the « master » instance. Itâs not the case yet in Gladys, but the idea of this « master » was to have, in the future, detached « pod » instances that can run remote services.
So Iâd suggest something like:
gladys/master/scene/[sceneSelector]/start
No specific body.
What do you think?
PS: I also did a small technical review: Run scene when receive message on MQTT by callemand · Pull Request #1911 · GladysAssistant/Gladys · GitHub
@pierre-gilles : I didnât know about the existence of the topic âč gladys/master/⊠âș.
I just modified my code accordingly. Itâs much simpler ![]()
Thanks for the technical review ![]()
Indeed itâs much simpler
Great PR, I tested it and it works for me!
Itâs merged and will be available in the next version of Gladys.
However Iâm not sure we should close this feature request because itâs not exactly what was asked (this was talking about a custom topic here)
Thanks @pierre-gilles for the merge ![]()
[quote=« pierre-gilles, post:7, topic:8127 »]
However, Iâm not sure
@pierre-gilles :
Here is the PR that implements the feature:
Tell me what you think ![]()
@Lokkye I left you a review! Add scene trigger : MQTT message by callemand · Pull Request #1913 · GladysAssistant/Gladys · GitHub
Iâd like to better understand the logic behind this development to understand the implementation choices
If you prefer to explain here in French rather than on GitHub in English, whichever you prefer!
@pierre-gilles : Thank you for the review.
So regarding the fact that I donât use the word « MQTT », I wanted to completely disconnect from the service. I do a lot of Clean Architecture in my work and therefore I like to separate concepts. I also wanted to avoid adding technical terms into Gladys. But itâs true that by doing that Iâm not necessarily any clearer.
Are we going to add other message queues in the near or not-too-distant future?
I understand the idea â however, from a user perspective, making things « ultra-generic » can just be confusing in practice, and itâs often better to be « ultra-specific », which allows using the right vocabulary.
UX level
In this case, a user who wants to connect an external MQTT script will inevitably look for the word « MQTT » as a trigger. Sure itâs technical, but anyone who wants that is technical.
If MQTT isnât mentioned anywhere, itâs impossible to know what that means ![]()
Even if in the future we have other queue technologies, we can create other triggers specific to those technologies.
If we take the example of Zapier (https://zapier.com/), when you select a trigger, they offer all the possible technologies directly so itâs clear:
I think we can mention MQTT in this case and talk about MQTT throughout the code without problems ![]()
Implementation level
Iâm not sure the implementation makes sense for this specific case, notably the use of eventEmitters to cancel triggers and set triggers, because we donât have a guarantee that the code will execute before moving on.
In the current implementation, nothing tells me that the listener:
this.gladys.event.on(EVENTS.MESSAGE_QUEUE.UNSUBSCRIBE, this.handleGladysEventUnsubscribe.bind(this));
Will actually be executed before:
this.gladys.event.on(EVENTS.MESSAGE_QUEUE.SUBSCRIBE, this.handleGladysEventSubscribe.bind(this));
So potentially, if I edit my scene, my listener is added a second time then removed and so weâre in a « messed-up » state.
Not sure we have a choice; I think we need to call this.service.mqtt in the scene. Besides, generally when we go from Gladys to the services, thatâs what we do in the rest of the code (for example in the Telegram integration thatâs what we do).
What do you think?
Ok, I understand better.
Yes, after thinking about it youâre completely right ![]()
I didnât think the « core » could be directly linked with the services. So we also need to handle the fact that the service isnât enabled ![]()
Iâll take care of that ![]()
[quote=« Lokkye, post:13, topic:8127 »]
I
@pierre-gilles : I have made the changes based on your feedback.
Great! Iâll check that out today ![]()
Super cool @Lokkye, it works perfectly for me like this ![]()
Iâve left you a few comments but nothing major ![]()
@pierre-gilles : Iâve just made the changes based on your feedback.
Feel free to tell me if I missed anything. ![]()
Thanks for the fixes, itâs fine with me and it will be included in the next Gladys release! ![]()
This feature is available in Gladys Assistant 4.31! ![]()
Iâm closing this thread to free up the votes, feel free to create another thread if you encounter bugs with this feature ![]()