Hi all,
I’m still on openHAB 2.5 - I know I should look at upgrading to 3.x, but I don’t have the time at the moment…
I do have one minor query about integrating the new Shelly Plus range, which has massively complicated their MQTT data compared to the nice, simple, easy previous versions
I’m using an i4, which has 4 inputs, and I wish to use them for triggering existing item(s) I have for opening my garage door and gate, as well as toggling on/off a compressor (the i4 won’t be the only way to switch this on/off via openHAB - I might use the app, or Alexa etc).
The MQTT I’m getting is like this:
topic: shellyi4plus-xxxxx/events/rpc
{
"src": "shellyplusi4-xxxxx",
"dst": "shellyplusi4-xxxxx/events",
"method": "NotifyEvent",
"params": {
"ts": 1652210605.17,
"events": [
{
"component": "input:0",
"id": 0,
"event": "btn_down",
"ts": 1652210605.17
}
]
}
}
Followed by:
{
"src": "shellyplusi4-xxxxx",
"dst": "shellyplusi4-xxxxx/events",
"method": "NotifyEvent",
"params": {
"ts": 1652210605.34,
"events": [
{
"component": "input:0",
"id": 0,
"event": "btn_up",
"ts": 1652210605.34
}
]
}
}
Followed by:
{
"src": "shellyplusi4-xxxxx",
"dst": "shellyplusi4-xxxxx/events",
"method": "NotifyEvent",
"params": {
"ts": 1652210605.67,
"events": [
{
"component": "input:0",
"id": 0,
"event": "single_push",
"ts": 1652210605.67
}
]
}
}
or
{
"src": "shellyplusi4-xxxxx",
"dst": "shellyplusi4-xxxxx/events",
"method": "NotifyEvent",
"params": {
"ts": 1652210605.67,
"events": [
{
"component": "input:0",
"id": 0,
"event": "double_push",
"ts": 1652210605.67
}
]
}
}
I’m (currently) only interested in the single_push
event - of course once I get the syntax down, then I can apply it to any other message types (double-push, long-push etc)
All 4 inputs will send a message on the same topic, the only identifier being the id
within the JSON.
I have looked at other topics here (such as Shelly plus i4) but these are referencing openHAB 3 and its UI-based MQTT configuration, and I’m not entirely sure if it’s totally relevant.
I got this far:
mqtt="<[mosquitto:shellyplusi4-a8032ab1ca7c/events/rpc:state:JSONPATH($.params.events[:1].event.single_push)]"
However the log shows the following error:
Error processing MQTT message.
java.util.regex.PatternSyntaxException: Unmatched closing ')' near index 19
1].event.single_push)
^
As far as I can tell, I’ve got the corresponding number of opening and closing brackets of all types!
Any advice or assistance anyone can give will be greatly appreciated to get this going!
Thank you!