Here is my situation. I am running OpenRemote locally with I have two assets configured and a Python code that sends them data.
This is what I would like to do. Through Python, I want to be able to send data to asset1 which will pass on the information to asset2 (I have created a flow rule for that) and then asset2 would send this data back to the Python code (basically creating a close loop).
I am able to: send the data to asset1 using python, pass on the info from asset1 to asset2 BUT I am unable to automatically send the data from asset2 to Python. The only way that I am able to do so is in the OpenRemote Manager UI by pressing the arrow next to the JSON data that I want to send over.
I have looked around and found some similar topics and it seems that I need to use a MQTT Agent and link it to the Topic that I want to sent over to Python but I cannot find any documentation about it and thus I am struggling quite a lot to make it work.
Can anyone direct me to possible documentation or knows how to do so?
could you describe what you actually trying to achieve?
The PAHOMQTT Lib can subscribe and publish, since the paho client is connected, he can subscribe to any topic.
I am trying to get OpenRemote to automatically send JSON files to my python code.
For example, when asset2 receives a JSON file, I would like it to automatically send said data to any MQTT client that is subscribed to the topic.
At the moment with my python code, I am able to subscribe and receive a JSON file from an asset in OpenRemote but only if I manually press the arrow next to the attribute while my code is connected.
I would like it to be automated so that I don’t have to click it myself every time.
Could it maybe be done using the Groovy rule?
then you just have to subscribe to the attribute of asset2, you don’t have to publish anything manually.
If you want, you can show your python code.
Sure thing here is my code:
OpenRemote_code.zip (1.9 KB)
(I have zipped it because the forum doesn’t allow me to directly upload my python code)
There is a loop created at the bottom where the subscribe action happens (line 152) and the code should receive a JSON load named “Final_E_program”. Let me know if you need any clarification about the code.
Thanks for the help!
the code seems ok, could you show a screenshot of your flow?
Next time you could also use pastebin.
Well now for some reason it is working properly! Maybe I had to restart python, either way, thanks for the help!
Glad you got it working. If you have any further questions, just ask.