gavinying / modpoll

A New Command-line Tool for Modbus and MQTT
https://gavinying.github.io/modpoll
MIT License
84 stars 17 forks source link

Command Line option to assist with specific subscribe and publish topics #54

Closed icuhamW9 closed 2 months ago

icuhamW9 commented 2 months ago

I'm running a command line with the --mqtt-topic-prefix included and trying to comply with a broker's strict requirements. I need to publish to "devices//state" and I do not have permission to subscribe to /+/set. I believe the automatic subscribe attempt causes an immediate disconnect from the session because it never logs a publish attempt. I only need to publish and I'd like to directly target the publish topic (ie. /state) without the automatic addition of the device name from the config.

I've tried options like the following: --mqtt-topic-prefix projects/myProject/registries/registry/devices/ <-- this is what I think the script anticipates --mqtt-topic-prefix projects/myProject/registries/registry/devices/deviceId/ --mqtt-topic-prefix projects/myProject/registries/registry/devices/deviceId/state/ <-- this is what I really want

This is the form of error I receive using the first option above: deviceId does not have permission to subscribe to to projects/myProject/registries/registry/devices/+/set

I've tried the prefix with and without a leading "/"

Am I using the command line options incorrectly? Can the automatic subscribe be bypassed somehow? Can the publish topic be forced without the automatic addition of the device id, since this necessitates trying a config line like "device,mydevice/state/,1,," to work around the "/state" publish requirement?

If no option is possible, could a command line option be added to circumvent the subscribe on connect, or give it a user defined format? If I could subscribe to "deviceId/config" instead of "+/set" this might work. Thanks!

gavinying commented 2 months ago

Hi @icuhamW9 , I see your point, there is a limitation in current version regarding MQTT topics. I will take your request into the roadmap, thinking of using topic pattern to replace topic prefix. Thanks for your interest in modpoll tool and sharing us your use cases.