TheZlodziej / mqtt-simulator

Python app that lets you simulate data flow over mqtt. It allows you to publish complex, random objects as well as simple value on given mqtt topic. Easy to setup and use from both GUI and CLI mode.
7 stars 1 forks source link

Group topics and values. #7

Open AnonymousWebHacker opened 5 months ago

AnonymousWebHacker commented 5 months ago

I can have 3 topics sending to topic /sensor/temp.

It is more logical to add them in a single configuration than to make a separate topic

TheZlodziej commented 5 months ago

It is impossible - topic name is a key in config thus you cannot have 2 with the same name. It also does not really make sense to me to have multiple ones in a simulator.

AnonymousWebHacker commented 5 months ago

Suppose you have a circuit called JHJSAU26 which publishes data in the form circuit/JHJSSAU26/temp , circuit/JHJSSAU26/preasure , circuit/JHJSSAU26/humidity. With your mqtt-simulator, the solution is to publish 3 separate topics and in each topic it would be generated by random number functions or pre-created functions such as gps, temp.etc. So far everything is great

But what happens when you have several circuits, for example JHJSSAU26, JHJSSAU27, JHJSSAU28 or simply Circuit1, circuit2...etc

TheZlodziej commented 5 months ago

All right, got you. Yeah I never needed that for my use case but sending different data to the same topic (and I might need it for my next project actually 🤪). I'll try to look into that in the near future as it's a breaking feature (current config would not work when the feature is added).

AnonymousWebHacker commented 5 months ago

In my case, more of a Linux user, I use a bash that generates random numbers from min to maximum in each variable and at the end, I send via mqtt a topic example, circuit1/sensors/data and a json is sent with all the data.

Maybe it will be of some use to you.

Your mqtt-simulator is very cool and more with the latest features like temp, gps...etc but it is still very... simple to use.

It is not useful when you are going to generate, for example, several circuits that send a specific topic circuit_number/sensors/data with a json of data including temp, gps ..etc

AnonymousWebHacker commented 5 months ago

Example, an idea.

The idea would be to specify a topic, circuit1/sensors/ and in that topic:

1 - choose whether to send separate raw or json themes.

2 - Choose what data would go in that json or separately.

3 - Think about the idea that perhaps the user wants to send a json in a topic with data such as temp, gps, pressure, humidity, some name...etc.

We solved https://github.com/TheZlodziej/mqtt-simulator/issues/6 y https://github.com/TheZlodziej/mqtt-simulator/issues/5 5 since each theme would have its theme configuration, its broker address, credentials, etc.

TheZlodziej commented 4 months ago

I just added support for sending data from multiple entries to the same topic (which made more sense to me). Keep in mind that it is breaking feature, although if you look at readme.md example for "manual setup" it is easy to migrate (simply add "topic" key in your config.json and change the key in "topics" to a unique one [it is no longer displayed, used only for UI to not be generated every time you add/remove/update topic])