Unable to set Raw UserCode
I'm trying to program add tags to an RFiD reader. The device has ExposeRawUserCodes set to true, because the codes have non ascii characters in them, so I am trying to use the values associated with "Raw UserCode" and "Raw UserCode Index" as follows:
- Set Raw UserCode Index to 2. I then see the existing value of the code echoed back in "Raw UserCode"
- Set Raw UserCode to a hex string
The second set value fails each time with "Index 0 is out of range of UserCodeCount", so it looks like setting the index is having no effect.
I found a workaround: if I set the value of "Raw UserCode Index" to the desired slot number in the ozwcache file, restart ozwdaemon and then set the Raw UserCode, it successfully sends the code to the device. I also tried setting the value for "User Code 2" directly, but unfortunately the RFiD tag has a zero byte in the middle of the code so the string gets truncated somewhere.
I've had a quick look at the code: in UserCode::SetValue() - in the block for ValueID_Index_UserCode::RawValueIndex I think we need to call Refresh on the underlying value from the store in order to persist it?
Logs:
2020-10-27 22:45:25.098580454 [20201027 22:45:25.098 UTC] [ozw.mqtt.commands] [debug]: Got "OpenZWave/1/command/setvalue/" Message: "{\n \"ValueIDKey\": 72902019124871190, \"Value\": 2\n}"
2020-10-27 22:45:25.099881051 [20201027 22:45:25.099 UTC] [ozw.mqtt.commands.setValue] [info]: Setting 72902019124871190 to Value QVariant(uint, 2)
2020-10-27 22:45:25.100590876 [20201027 22:45:25.100 UTC] [ozw.values] [debug]: setData Called for Row 312 With Value QVariant(uint, 2)
2020-10-27 22:45:25.101045557 [20201027 22:45:25.100 UTC] [ozw.values] [debug]: valueModel Changed! QTOZW_ValueIds::Value - 312 : QVariant(uint, 2)
2020-10-27 22:45:25.101337813 [20201027 22:45:25.101 UTC] [ozw.values] [debug]: valueModel Changed! vidKey: 72902019124871190 QVariant(uint, 2)
2020-10-27 22:45:25.101680864 [20201027 22:45:25.101 UTC] [ozw.library] [info]: Info - Node: 9 Value::Set - COMMAND_CLASS_USER_CODE - Raw UserCode Index - 259 - 1 - 2
2020-10-27 22:45:25.102101082 [20201027 22:45:25.101 UTC] [ozw.library] [debug]: Detail - Node: 9 Value Updated: old value=aff704b0, new value=ae535d80, type=raw
2020-10-27 22:45:25.102462708 [20201027 22:45:25.102 UTC] [ozw.library] [debug]: Detail - Node: 9 Changes to this value are not verified
2020-10-27 22:45:25.103020165 [20201027 22:45:25.102 UTC] [ozw.library] [debug]: Detail - Node: 9 Notification: ValueChanged CC: COMMAND_CLASS_USER_CODE Instance: 1 Index: 258
2020-10-27 22:45:25.103428271 [20201027 22:45:25.102 UTC] [ozw.mqtt.commands] [info]: Processed Message for "setvalue" : "{\n \"ValueIDKey\": 72902019124871190, \"Value\": 2\n}"
2020-10-27 22:45:25.103867063 [20201027 22:45:25.103 UTC] [ozw.notifications] [debug]: Notification pvt_valueChanged: 72620544148160537 Thread: 0xb3cc7010
2020-10-27 22:45:25.107452172 [20201027 22:45:25.107 UTC] [ozw.mqtt.publisher] [debug]: Publishing Event valueChanged: 72620544148160537
2020-10-27 22:45:39.202059919 [20201027 22:45:39.201 UTC] [ozw.mqtt.publisher] [debug]: "Tue Oct 27 22:45:39 2020 PingResponse\n"
2020-10-27 22:45:44.775244332 [20201027 22:45:44.774 UTC] [ozw.mqtt.commands] [debug]: Got "OpenZWave/1/command/setvalue/" Message: "{\"ValueIDKey\": 72620544148160537, \"Value\": \"31323331000000000000\"}\n"
2020-10-27 22:45:44.776766630 [20201027 22:45:44.776 UTC] [ozw.mqtt.commands.setValue] [info]: Setting 72620544148160537 to Value QVariant(QByteArray, "1231\x00\x00\x00\x00\x00\x00")
2020-10-27 22:45:44.777484400 [20201027 22:45:44.777 UTC] [ozw.values] [debug]: setData Called for Row 311 With Value QVariant(QByteArray, "1231\x00\x00\x00\x00\x00\x00")
2020-10-27 22:45:44.777925673 [20201027 22:45:44.777 UTC] [ozw.values] [debug]: valueModel Changed! QTOZW_ValueIds::Value - 311 : QVariant(QByteArray, "1231\x00\x00\x00\x00\x00\x00")
2020-10-27 22:45:44.778346761 [20201027 22:45:44.778 UTC] [ozw.values] [debug]: valueModel Changed! vidKey: 72620544148160537 QVariant(QByteArray, "1231\x00\x00\x00\x00\x00\x00")
2020-10-27 22:45:44.778798552 [20201027 22:45:44.778 UTC] [ozw.library] [info]: Info - Node: 9 Value::Set - COMMAND_CLASS_USER_CODE - Raw UserCode - 258 - 1 - 0x31 0x32 0x33 0x31 0x00 0x00 0x00 0x00 0x00 0x00
2020-10-27 22:45:44.779318158 [20201027 22:45:44.779 UTC] [ozw.library] [warning]: Warning - Node: 9 Index 0 is out of range of UserCodeCount
2020-10-27 22:45:44.780036854 [20201027 22:45:44.779 UTC] [ozw.mqtt.commands] [info]: Processed Message for "setvalue" : "{\"ValueIDKey\": 72620544148160537, \"Value\": \"31323331000000000000\"}\n"