I need help to filter output of result mqtt

from topic tele/livingroom/RESULT i get this output:

{"Ping":{"192.168.0.111":{"Reachable":true,"IP":"192.168.0.111","Success":4,"Timeout":0,"MinTime":4,"MaxTime":16,"AvgTime":7}}}

I am not interested to seeing all the output only Reachable :true and IP :192.168.0.111
I would appreciate advice on how to set it up in the item’s channel or even through a rule
thanks

This is a JSON Object.

And this is, how it looks like, when prettified:

{
	"Ping": {
		"192.168.0.111": {
			"Reachable": true,
			"IP": "192.168.0.111",
			"Success": 4,
			"Timeout": 0,
			"MinTime": 4,
			"MaxTime": 16,
			"AvgTime": 7
		}
	}
}

I’m pretty sure that IP is fix (it’s the name of the node)
To get the Reachable information into an Item (switch would be fine?) You’ll have to change some settings for the mqtt channel.

  - id: living
    channelTypeUID: mqtt:switch
    label: Living room reachable
    description: ""
    configuration:
      stateTopic: tele/livingroom/RESULT
      transformationPattern: JSONPATH:$.Ping["192.168.0.111"].Reachable
      off: "false"
      on: "true"

If the ip will change from time to time, you can use this JSONPATH instead:

      JSONPATH:$.Ping[0].Reachable

And creating another channel to get the current ip is easy enough (has to be a string channel, of course).

Thank you very much, Exactly what I was looking for

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.