[SOLVED] Break up string into sections

I have a button which returns this MQTT string.

What code do i need to do to convert this


to just give me the ip address section?

You need to use the JSONPATH transform
Can you post your item definition, please?

I have been able to get this as a string


using this code

rule "ip address Downlights"
	Item FrontDownlight_IP received command
	val IPStringdownlights = FrontDownlight_IP.state.toString.split(",")

This is my items file

String FrontDownlight_IP 	"Get Info"  										{ mqtt="<[broker:stat/FrontDownlightsSonoff/STATUS5:state:default],>[broker:cmnd/FrontDownlightsSonoff/STATUS:command:*:5]" }
String FrontDownlight_IP_String "Info [%s]"	 									

and this is what i get as a string return


I literally just want the IP address as Text.

OK, there is a way to get this directly from the mqtt binding with the JSONPATH transform
It is a very powerful tool to extract values from json strings


String FrontDownlight_IP 	"Get Info"  										{ mqtt="<[broker:stat/FrontDownlightsSonoff/STATUS5:state:JSONPATH($.StatusNET.IPAddress)],>[broker:cmnd/FrontDownlightsSonoff/STATUS:command:*:5]" }
1 Like

Thanks heaps for that.

Just reading up on the sonoff devices. you can actually send IPAddress1 as a command and it responds with just that string. which works great.
Still you helped me though marked as complete

What firmware are you using i sonoff? Curiosity question.

Whatever the latest is, they were only uploaded within the last week.