Hello,
i want to announce / display at OH2 if a Firmware update for the Shelly devices is aviable. All Shellys that connected to the broker report by the MQTT publish shellies/command/ announce a json formatted answer like this: shellies/<shellymodel>-<deviceid>/announce
The problem is that all of the devices respond almost simultaneously.
Is it possible to summarize the JSON answers in groups sorted by the model and to generate an output for the individual model groups?
You have tagged this post with mqtt - is that what you’re using to communicate with these Shelly devices, and not the binding?
If you’re using MQTT, why not add a new Channel to each device Thing, and those Channels subscribe to the respective announce topic?
For example, you presumably already have a device Thing for your shellyswitch25-xxxx - install the JSONPATH Transformation Service if you don’t have it already, and add the following Channel:
Type switch:new_fw "New firmware available" [
stateTopic="shellies/SHSW-25-shellyswitch25-xxxx/announce",
transformationPattern ="JSONPATH:$.new_fw",
on="true",
off="false"
]
Obviously, adjust the topic to suite - I only copied and pasted the id and model from your JSON extracts.
For the next device, the Channel could be:
Type switch:new_fw "New firmware available" [
stateTopic="shellies/SHPLG-S-shellyplug-s-xxxx/announce",
transformationPattern ="JSONPATH:$.new_fw",
on="true",
off="false"
]
It does not matter if you use the binding or MQTT, if the device is not online (connected to the network), there can’t be any indication of an available firmware update. These checks run inside the shelly devices…
Ah, I think I see what you mean now, and I think I also understand this from your first post:
So, for a device model, such as the SHSW-25:
You have more than 1 of these devices
You want to display a single Item which tells you whether firmware is available for that particular model
Is that correct?
If so, you will still need a Channel for each device Thing, but you can use a Group Item to collect them all together. For example, let’s say you have the Items:
So we have three SHSW-25 devices, with the Channels I created previously, and they’re all part of the Group Item gSHSW-25_new_fw. Now, we can define the Group Item:
Group:Switch:OR(ON,OFF) gSHSW-25_new_fw
What this means is that the group gSHSW-25_new_fw will be ON if any of its members is ON. In other words, if any of the Shelly devices has a “new_fw” : true response, the Group will switch ON. More Group magic in the docs.
Not sure I understand what’s going on here: is every device publishing a message to exactly the same topic, at the same time? What is that topic? shellies/announce/#?
No there is no level under this topic.
I think this is to check which shelly devices is online at the network. Like a call in the room and everybody who hear it answer who he is.
OK, so if that’s the case, then you can do the following.
Adjust the Channel from my first example to the following. You will need one of these Channels in each of your device Things. Also install the REGEX Transformation Service.
Type switch:new_fw "New firmware available" [
stateTopic="shellies/announce",
transformationPattern ="REGEX:(.*shellyswitch25-xxxx.*)∩JSONPATH:$.new_fw",
on="true",
off="false"
]
The shellyswitch25-xxxx is the id of your device, so you need to change this to the correct one for each device Thing.
What this does is use REGEX to scan the entire JSON string for the string shellyswitch25-xxxx. If that string is found (as part of the id key/value pair), the transformation moves on to the JSONPATH, and will extract the new_fw value. If the string is not found then the message is ignored by this Channel.
Once that’s done, you can continue with the Group Item idea!