Reading the state of a mqtt switch based on multiple values in a JSON string

Hi,

I am currently trying to integrate a OXRS device (https://oxrs.io/) that communicates via JSON over mqtt. I am using this to read the state of switches and sensors connected to the device.

When a switch or sensor is triggered it sends something like the following to a single mqtt topic:

{
  "port": 5,
  "channel": 1,
  "index": 17,
  "type": "contact",
  "event": "closed"
}

In this example I am interested in the “type” and “event” information only if “index” = 17. If “index” does not equal 17 then the message should be ignored.

My question is - How do I first check to see if “index” is equal to 17 before reading the “type” and “event” values?

Thank you

You could try this example, found in the OXRS docs… OXRS Home Assistant integrations | OXRS Docs