“Outgoing” is the clue that it applies to outgoing messages, i.e. those that openHAB publishes to MQTT.
You want Incoming … as used for state updates.
Why not extract the ‘type’, and either -
put it in an Item state for a rule to examine when updates
or
use it trigger an event, with the type as event payload.
These events don’t represent state though, right? They represent a momentary event. So you probably shouldn’t be using a State Channel linked to an Item anyway. Instead use a Trigger Channel and trigger your rule from the Channel directly.
In that rule you can parse the JSON and do a “sync” or “refresh” using the transform Action (ignoring the rest) so you would only need the one rule.
Alternatively, if you did want to keep this as state, you could use a text Channel and a String Item and the REGEX chained to a JSONPATH to extract the type. Then you can trigger the rule when the Item receives an update to “sync” or “refresh”.
There are lots of ways to go about this sort of thing, the best depends on details not provided in the question.
Hi @rossko57 , I can’t extract the type because it would only pass that to the rule via the item then, wouldn’t it? I need all the other things in the message for using in the rule too. So i need the whole payload.
@rlkoshak , no I don’t need state, it’s just an event to process really so the channel trigger might work, just never used one before!
The reason I’d prefer it filtered to 2 rules is just to keep it separate for my readability. It might be ok to have one rule, as some code is common in each. It’s just they might be big and i think it might be easier if 2.