Page 1 of 1

MQTT Does not Match Push2Run Docs & A suggestion for how I expected it to work.

Posted: Mon May 27, 2024 4:21 pm
by coreyzev
I tagged Rob about this on reddit but I'll make a formal post here for continuity and any further discussion. I didnt seem to explain well what the problem was on reddit.

After struggling to get MQTT to work with Home Assistant for a few hours, I ultimately stumbled upon the realization that the P2R docs do not match its actual implementation. I assume this is probably just a lapse in desired planning, and actual execution, and maybe forgetting to go back and change it.

To start, here is a picture from the "setup mqtt" push2run docs seen here:
Image

It implies that one needs to place the mqtt topic as the "listen for" value. It also suggests that adding a $ will allow you to pass specifically the mqtt payload through your parameters to whatever you're executing.

e.g. (also my desired functionality)
I would be able to have my broker publish topics such as "push2run/calculator" or "push2run/shutdown" or "push2run/notify" and each one would be set up with a respective card and "listen for". And that for example on "notify" i could pass a payload such as "dinner is ready" and that would pass that payload thru to some notify tool to display the payload.
Using this method I would just set the MQTT option to listen on "push2run/#" and it would pull it all in.

This is what the docs explain to me, and I think it's a superior way for p2r to have handled MQTT. This also aligns better with how MQTT seems to be designed.

But in reality that is not how it works.

The way it actually works, is you set a single topic for push2run to listen on (or as many as you want, it doesnt matter) and only the payload is what activates the cards. This prevents you from being able to pass useful information through on the payload.

e.g. (for anyone who finds this when struggling with HA & P2R like I was) (though honestly, hopefully it changes to match the docs before you see this):
1. set your mqtt broker to publish to `push2run`
2. set p2r to listen to `push2run`
3. set the Calculator card to listen for the payload `calculator`
4. prepare a message from your mqtt broker to `push2run`, QoS 2, with the payload `calculator`
5. send it
6. The card will run.
---

I understand that changing push2run to match the existing documentation would break the mqtt install for those who use it, but honestly I think this is a good breaking change. It would work in line with how it was described in Rob's docs and how MQTT is expected to work. (in my experience).

If how P2R's mqtt execution doesnt change, then the docs need to be entirely rewritten to match how it actually works.

Re: MQTT Does not Match Push2Run Docs & A suggestion for how I expected it to work.

Posted: Mon May 27, 2024 9:23 pm
by RobLatour
Hi coreyzev,

Thanks for posting this and for the suggestion.

The help has been updated to include the following (under the MQTT section):
Once a MQTT topic is subscribed to, and when a MQTT publication with a matching topic is received by Push2Run, Push2Run will check if any of your Push2Run cards have a 'Listen for' field matching the MQTT publication's payload, and if so Push2Run will run those matching Push2Run cards.
You may need to press F5 to refresh the page in your browser to see the change.

Having that said, the way the MQTT handling works is in keeping with how other processing works. For example with Pushbullet, Push2Run triggers on the Pushbullet title and actions on the Pushbullet message. With Pushover, Push2run triggers on the Pushover device name, and actions on the Pushover message. That is why it is currently set up to have Push2run trigger on the MQTT topic, and action on the MQTT payload.

Regardless, can you please look at the way your doing things - if you can't find a way to publish to a topic and react to just the payload with, for example, the payload being just ''shutdown" or "calculator" then let me know and I can see if I can add an option to combine the topic and payload to evaluated for action - that is to say what the listen field would be compared against is "push2run/calculator" instead of just "calculator" as is the case now.

Please let me know.