Error loading Zigbee State -- parse error

I’m running openhabian 1.4.1 on the openhab snapshot channel, so I’m running 2.4.0-SNAPSHOT. I have a HUSBZB-1, which is (I think) installed properly for Zwave and Zigbee. I have the Ember EM35x Coordinator present and online. I’m trying to connect a Stelpro Maestro thermostat. I was able to have openhab discover the thermostat. The device showed up in the Paper UI inbox and I added the Thing. However, the Maestro item does not show as online when I restart openhab. There is only the ember controller xml file in {USERDATA}/zigbee…no file for the Maestro. I see the error below in the zigbee log. The Paper UI shows this when I look at the properties of the device:

|hardwareVersion |1|
|---|---|
|modelId |MaestroStat»ï§C¤):|
|vendor |Stelpro|
|zigbee_datecode |20180509 00105|
|zigbee_devices |[]|
|zigbee_lastupdate ||
|zigbee_logicaltype |ROUTER|
|zigbee_neighbors |[{"joining":"ENABLED","address":"0","depth":"0","lqi":"49","macaddress":"000D6F001200E2E0"}]|
|zigbee_networkaddress |33805|
|zigbee_powerlevel |FULL|
|zigbee_powermode |RECEIVER_ON_IDLE|
|zigbee_powersource |MAINS|
|zigbee_powersources |[MAINS, DISPOSABLE_BATTERY, RECHARGABLE_BATTERY]|
|zigbee_routes |[{"next_hop":"0","destination":"0","state":"ACTIVE"}]|
|zigbee_stkversion |24|
|zigbee_zclversion |2|

zigbee log:

2018-10-12 10:02:54.639 [ERROR] [org.openhab.binding.zigbee.internal.ZigBeeNetworkStateSerializerImpl] - Error loading ZigBee state
com.thoughtworks.xstream.converters.ConversionException:  : ParseError at [row,col]:[167,57]
Message: Character reference "&# :  : ParseError at [row,col]:[167,57]
Message: Character reference "&#
---- Debugging information ----
message             :  : ParseError at [row,col]:[167,57]
Message: Character reference "&#
cause-exception     : com.thoughtworks.xstream.io.StreamException
cause-message       :  : ParseError at [row,col]:[167,57]
Message: Character reference "&#
class               : java.lang.String
required-type       : java.lang.String
converter-type      : com.thoughtworks.xstream.converters.SingleValueConverterWrapper
wrapped-converter   : com.thoughtworks.xstream.converters.basic.StringConverter
path                : /list/ZigBeeNode/endpoints/ZigBeeEndpoint/inputClusters/ZclCluster/attributes/entry[6]/ZclAttribute/lastValue
line number         : 167
class[1]            : com.zsmartsystems.zigbee.zcl.ZclAttribute
converter-type[1]   : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2]            : java.util.HashMap
converter-type[2]   : com.thoughtworks.xstream.converters.collections.MapConverter
class[3]            : com.zsmartsystems.zigbee.dao.ZclClusterDao
class[4]            : java.util.ArrayList
converter-type[3]   : com.thoughtworks.xstream.converters.collections.CollectionConverter
class[5]            : com.zsmartsystems.zigbee.dao.ZigBeeEndpointDao
class[6]            : com.zsmartsystems.zigbee.dao.ZigBeeNodeDao
version             : 1.4.7
-------------------------------
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79) ~[?:?]
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65) ~[?:?]
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66) ~[?:?]
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:474) ~[?:?]
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:406) ~[?:?]
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:257) ~[?:?]
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72) ~[?:?]
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65) ~[?:?]
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66) ~[?:?]
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50) ~[?:?]
        at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:71) ~[?:?]
        at com.thoughtworks.xstream.converters.collections.MapConverter.putCurrentEntryIntoMap(MapConverter.java:110) ~[?:?]
        at com.thoughtworks.xstream.converters.collections.MapConverter.populateMap(MapConverter.java:98) ~[?:?]
        at com.thoughtworks.xstream.converters.collections.MapConverter.populateMap(MapConverter.java:92) ~[?:?]
        at com.thoughtworks.xstream.converters.collections.MapConverter.unmarshal(MapConverter.java:87) ~[?:?]
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72) ~[?:?]
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65) ~[?:?]
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66) ~[?:?]
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:474) ~[?:?]
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:406) ~[?:?]
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:257) ~[?:?]
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72) ~[?:?]
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65) ~[?:?]
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66) ~[?:?]
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50) ~[?:?]

This is a very annoying feature of XStream - it writes out data that it can’t then read back in again :frowning: . I’ve come across this with ZWave and ZigBee and have tried to work around it where I’ve hit this, but it’s annoying…

Ultimately, this is caused by the device seemingly returning non printable characters in a character string. Currently I try and protect against this, but clearly it doesn’t catch all possibilities :frowning: .

If possible, can you get a debug log of this (see the binding readme for enabling debug for the libraries and binding)? I think if you delete this node from the XML file and restart the binding, then do a search and hopefully it should discover the device again, and if you have logging enabled during this, I would like to see this log as I can use this to try and write some tests for debugging.

Will do. Is it an encoding issue? E.g. UTF-8 vs Latin1?

Both reading and writing of the file use UTF-8 -:

writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));

Ok, I enabled debug logging, removed the existing Thing, and re-discovered it. Error is in the log, along with a pile of other stuff. The bits of the log file I extracted are 500K+, so I’m not pasting them here, but made a link:

Zigbee Log

Thanks. From a quick look I can see what I wanted to capture in here - I now need to work out what to do with it :wink: .

This issue should be resolved with the following update -:

However, this won’t flow into the binding for a while.

What I would recommend is to stop the binding, edit your XML file, do a search for “MaestroStat” and remove the extra characters off the end of the string. Save the XML and restart the binding - this should fix the error, and the binding should not update this parameter.

Thanks Chris! I followed the steps (add thing to openhab via PaperUI, shut down openhab2, edit xml file, start service), and I get the parsing exception again. Looks like the value for the zigbee items is also stored/cached somewhere else?

The exception is from the reading of this XML, so even if it’s stored elsewhere, that’s not what the exception is. Or is there now a different exception?

Is the XML still showing the edited XML or did something rewrite the XML somewhere?

Another thought - maybe there’s another corrupt string? The XML exception should list the line in the XML that has the error…

As usual you are right on the money. There were two places in the XML where the bogus characters were. The device is now showing up happily. However, it is only there as a generic device. Would the XML or a log be useful in fully supporting it?

Thanks!

What do you mean by this exactly?

In the ZigBee binding, the channels are detected automatically, so in general, no specific devices are supported as such. This is different to the ZWave binding.

You should see some channels - right? But you won’t see any thermostat channels as these aren’t supported at the moment. I’ve just bought a ZigBee thermostat for testing so I should be in a position to look at this in a week or so once it arrives.

I do have a humidity channel, but nothing for adjusting the set point, current temperature, etc. Here’s a screenshot:

Ok, that’s correct - this is not supported in the binding at the moment.

Allrighty. Anything I can do to assist?

No, not at the moment - I’ve purchased a ZigBee thermostat to debug this and add support for these channels. It should be here in the next week and I’ll look at this then…

Ok, thanks!

Hello, @chris. Any update on the Zigbee thermostat support? Thanks!

I have written part of it - the binding side is mostly complete. I also have a thermostat now to test with, but I’ve been tied up with some other things over the past couple of weeks so haven’t had the time to finish this. I will try and get the basic functions tested soon.

Great! Thanks!