It looks like the activityLevel
attribute is declared in the code as a string rather than a numeric type, so arithmetic operators are not available. That being said, from what I can see in the code, the sensor does indeed report numeric types for this (and the driver even converts them to an Integer when parsing). Until the actual maintainer of the driver has a chance to look at this, my suggestion in the meantime would be to edit the line in the driver that looks like this (on line 43 in the current version but may vary on others):
attribute "activityLevel", "String"
to look like this:
attribute "activityLevel", "Number"
This is assuming there isn't some other reason this is declared as a string. I don't have one of these devices and can't test for sure, but it looks like the assumption elsewhere is that this will always be an integer value from the device.
I don't know nearly as much about these as Keith does, but since you haven't received a reply yet, here's my take on this:
- I think I've seen that error a time or two, especially if I just paired the device. Xiaomi device drivers parse the data received back manually instead of relying on built-in Hubitat methods due to the fact that they will occasionally send data that the Hubitat methods can't handle. Without debug logging enabled and the corresponding output (probably right before this, but again, debug logging needs to be on) from what it was trying to parse, I don't think it would be possible to say what this might have been, but the device was likely sending something that never came up in regular use and so wasn't being handled right. It could have also been sending garbage data for some reason (dying battery?).
- The "falling off" is likely to be a different issue. A driver can't cause a device to fall off, though if it's not parsing the data correctly, an event may not get generated. If you haven't seen this thread (mostly just the first post), it's pretty much required reading for using these outside Xiaomi's own system, e.g., on Hubitat: Xiaomi & Aqara Devices - Pairing & Keeping them connected
- I'm not sure what three flashes of the LED means, but my guess is either that the device can't find the parent or hub (only suggesting that because it's consistent with what you noticed) or maybe low battery. If you haven't checked the voltage (I'd do it manually instead of trusting the driver) or just replacing it to see if it helps, that would be worth doing and then re-pairing. But again, a re-pair won't help if it's not either consistently within range of the hub (probably risky) or routing through "compatible" repeaters (and having any that aren't is also risky) per the thread above.