999LV / BatteryLevel

Domoticz python plugin to display/log battery level of zwave devices
MIT License
9 stars 5 forks source link

Issues when reading ozwcache_0xc******.xml #9

Closed dobber81 closed 4 years ago

dobber81 commented 5 years ago

When using a RFID reader some characters in ozwcache does not compute as xml. This causes errors in BatteryLevel plugin.

2019-07-08 18:23:37.856 Error: (Battery monitoring Z-wave) Error reading openzwave file ./Config/ozwcache_0xc1efd261.xml: not well-formed (invalid token): line 10528, column 207

            <Value type="string" genre="user" instance="1" index="2" label="Code 2:" units="" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="�MyT*">
                <Help>UserCode 2</Help>
            </Value>
            <Value type="string" genre="user" instance="1" index="3" label="Code 3:" units="" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="�(2&#x0D;&#x01; &#x02;�$
                <Help>UserCode 3</Help>
            </Value>
            <Value type="string" genre="user" instance="1" index="4" label="Code 4:" units="" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="�&gt;qT*">

Is there a way to fix this by telling the script to ignore unreadable lines?

999LV commented 5 years ago

Looks like the error is raised by the xml python module and hence not within the scope of the plugin. I can think of three avenues:

  1. The RFID device manufacturer updates its firmware to remove the offending characters
  2. The python xml module code is made more robust
  3. The plugin code is modified to read xml files directly (and handle offending characters).

Obviously only the third option is within my reach, but I cannot devote time to it for now. Can you code ?

dobber81 commented 5 years ago

I posted on domoticz git and I think they will correct it on their side for my type of rfid reader: https://github.com/domoticz/domoticz/issues/3365

I do bash/expect scripting and can make some basic python stuff. But if the domoticz guys dont solve my problem I will give the battery level code a go.