Splitting a string

Hi All,

I’m working on getting a Daikin Zone controller + wifi module working with openhab.

Querying the Zone controller with a http query returns:
ret=OK,zone_name=Master;Study;Guest;US Living;DS Living; Zone6; Zone7; Zone8,zone_onoff=1;0;0;0;1;0;0;0

This output represents the names of the individual zones - separated by ; after ‘zone_name’ and also the states of these zones - separated by ; after zone_onoff

What I need to do is parse this string to populate the current values of each zone - the zone names isn’t important, other than the command to ‘set’ to new zone values needs to include the full zone_name string, so storing it would be useful.

Any tips on splitting the above?

Cheers,

Paul

Using the search function of this forum you could have found a thread like That.
I hope that helps!

OK thanks, I’d seen that post, just wondered if there was a more efficient way - seems I’ll need to call split a number of times to get all the parts I need, but if that’s the most efficient way then so be it…

Thanks!

OK, I’m making progress…

//urlmessage='ret=OK,zone_name=Master;Study;Guest;US Living;DS Living; Zone6; Zone7; Zone8,zone_onoff=1;0;0;0;1;0;0;0'    val String ret = urlmessage.split(',').get(0)
    val String zone_name = urlmessage.split(',').get(1)
    val String zone_onoff = urlmessage.split(',').get(2)
    logInfo("aczones",urlmessage);
    logInfo("aczones",ret);
    logInfo("aczones",zone_name);
    logInfo("aczones",zone_onoff);
    val String zone_onoff2 = zone_onoff.split('=').get(0)
    logInfo("aczones",zone_onoff2)

gives me…
2019-02-02 09:57:00.175 [INFO ] [lipse.smarthome.model.script.aczones] - ret=OK
2019-02-02 09:57:00.182 [INFO ] [lipse.smarthome.model.script.aczones] - zone_name=Master;Study;Guest;US Living;DS Living; Zone6; Zone7; Zone8
2019-02-02 09:57:00.187 [INFO ] [lipse.smarthome.model.script.aczones] - zone_onoff=1;0;0;0;1;0;0;0
2019-02-02 09:57:00.199 [INFO ] [lipse.smarthome.model.script.aczones] - zone_onoff

So now I just need to correctly parse ‘zone_onoff=1;0;0;0;1;0;0;0’ into the 8 zone states for the zone controllers.

I think in the finished product I’d add a little check to see if the first chunk contains “OK”, for basic confidence.

Yep, probably a good idea… meanwhile:
zone_onoff = zone_onoff.replace(‘zone_onoff=’,’’)

gets rid of the leading text, leading me with just the numbers to parse :slight_smile: