MQTT Automations - Parse JSON

I have a stream of events feeding in to MQTT. I want to set up an automation to run when a specific event is received. A sample of the JSON is below

{
    "time": "2020-06-23 10:22:54",
    "model": "Smoke detector GS 558",
    "id": 18504,
    "unit": 0,
    "learn": 0,
    "code": "f90900"
}

I can put the payload in the automation trigger but the time will change every time so won’t match the received payload. Is there any way I can tell the trigger just to inspect a specific field?

trigger.json.model for example.

I managed to find another post that did something with conditions:

{{ trigger.payload_json['id'] == 18504 }}

I can’t find any info on trigger.json.model hower?

Thanks!

if trigger.json is

{
    "time": "2020-06-23 10:22:54",
    "model": "Smoke detector GS 558",
    "id": 18504,
    "unit": 0,
    "learn": 0,
    "code": "f90900"
}

then
trigger.json.model is

Smoke detector GS 558

2 Likes

Hi,

I have the same smoke detector GS558 streamed to MQTT by RTL_433.

If I do understand correctly there isn’t any Boolean flag or similar changing when heat/smoke is reported but simply the sensor send that payload and only value changing is time?

Is it for this reason that @bleep-io you want to create a trigger (for an automation I guess) when payload is received?

…just trying to understand how to manage smoke alarm with my sensor

It’s actually not that smoke alarm but a doorbell. For some reason it maps to the above event in RTL_433.

Whenever the doorbell button is pressed I get that event.

Can I ask how you run RTL_433? I have it just running in a terminal windows but if I restart my server I have to manually start it again.

I use this:

Works very well on RPI3

1 Like