If I understand your question fully, you’re MQTT broker publishes messages in JSON format and you would like to extract values from that?
If this is correct then you can use the Value filters parameter of the Agent link to add a JSON path value filter that accepts a JSON path expression (see https://jsonpath.com/).
OK to publish you need to set the Publish topic parameter on your Agent link; you can then add the Write value parameter to you Agent link to specify a payload that should be sent on publish, this payload can have within it the special placeholder {$value} which will be replaced by the value that you actually write to the attribute.
Imagine you have a number attribute representing the brightness of a light (0-100) and you need to publish a JSON message like:
{
"brightness": 0-100
}
Well if you use the {$value} placeholder then you can dynamically inject the 0-100 value as it is written to the attribute:
{
"brightness": {$value}
}
If you want to publish a static message then don’t include the {$value} and whatever is in the Write value parameter should get published no matter what is sent to the attribute.
If this doesn’t cover your scenario then please provide more details.
NOTE: There was a bug in the Agent link UI which rendered the Write value parameter as single line input only this has been fixed in latest commit which will appear in the manager docker image shortly
my device send mqtt message automatically like this:
Subscription
shellies/shellyem-XXXXXX/emeter/0/returned_energy (value energy returned to the grid in Watt-minute)
once i subscribe to this topics i can read the value.
But some data on the device i need a publish action to received data like this:
2. Publish topics: shellies/shellyem-XXXXXX/relay/0/command (accepts on, off or toggle) Payload: On or OFF or togggle.
Now my question is how to create on Openremote a publish topics with payload.
If I use shellies/shellyem-XXXXXX/command Payload: announce
I think I understand a little more clearly; you want to subscribe to a topic but data is only published to that topic by first publishing.
Is this a one time request and static data is returned or do you need to keep sending the request periodically?
The MQTT Agent doesn’t currently support this; we have similar funcionality to this in the Websocket Agent I will need to look at providing something similar for MQTT Agent but until then you could use a rule to try and achieve it in combination with the Write value parameter and Rule state configuration item on the MQTT AgentagentStatus attribute:
Hi @sdepascali@Rich Can you please tell me how you receiving and send data . here I am able to connect MQTT Explorer with MQTT broker (Openremote) but I am not able to understand how to send a demo mqtt data also I am not correctly configure assets, attribute, rules. So please make a video where we can send and recived mqtt demo data.
It’s not clear if you’re trying to connect to the OpenRemote MQTT broker (discussed in this post) or you are trying to connect OpenRemote to an external MQTT broker as discussed here.
MQTT explorer is an MQTT client for connecting to an MQTT broker. You don’t need to create an MQTT agent in OpenRemote to be able to connect to our broker, just need a service user which is clearly described in the article you have referenced.
hi @Rich by following the link Tutorial: Connect your MQTT Client · openremote/openremote Wiki · GitHub. I am able to Establish a connection from client to broker. but I have doubt in “Subscribe to attributes using the MQTT API” and “Publish attribute values from the MQTT client”. where I need to write this example-- master/client123/attribute/subscribeAttribute/6xIa9MkpZuR7slaUGB6OTZ and this example–master/client123/writeattributevalue/writeAttribute/6xIa9MkpZuR7slaUGB6OTZin mqtt explorer or open remote. if openremote then where in openremote.
Hi @Rich
I am following the link https://github.com/openremote/openremote/wiki/Tutorial%3A-Connect-your-MQTT-Client and successfully Subscribe attributes using the MQTT API. but I don’t know how to Publish attribute values from the MQTT client.
there are some step that are mention to publish but I am not able to understand 1—how to Define the correct topic. For directly writing an attribute value:{realm}/{clientId}/attribute/{attributeName}/{assetId}
2-- 1. Send the JSON over this topic. For a Number, this is really simple: 23
3–. Go to the Manager and check if the value updated!
Thank you
vicky kumar
I need to write topic manually of writeAttribute. also I write same writeattribut in “ADVANCE” of mqtt explorer. so am I doing correct or not.
Also have some document or link how to connect , send and receive data openremote with raspberry pi
Hello
I have successfully connect my esp8266 MQTT client to OpenRemote MQTT server.
I have published the sensor values from esp with " {realm}/{clientId}/attribute/{attributeName}/{assetId}" based on Wiki.
The question is, how can i send multiple values of my esp with one JSON data?
for example, i want to send Temperature and Humidity like this: