-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ResourceItem cannot hold UINT64 values #8053
Comments
I'm not sure what would be the best approach to address this. We could probably simply cast the value to Changing the internal representation in
|
The change of items to |
From my perspective Rules can be refined to properly compare values, currently it's a bit naive with things like: if (c->op() == RuleCondition::OpEqual)
{
if (c->numericValue() != item->toNumber())
{
return false;
}
if (item == eItem && e.num() == e.numPrevious())
{
return false; // item was not changed
}
} Here I guess most of the time so far we get away with that since likely not many rules need the larger numbers. This can and should be fixed anyway. I have an idea how to make this with little effort, also accounting for safe signed vs unsigned 64-bit comparisons. The elephant in the room is the Javascript and JSON representation. Here we can only represent 52-bit values as numeric. While the following 64-bit number is perfectly valid JSON according to the spec, most parsers will read the value as 64-bit double and we're back to 52-bit precision. {
"n": 18446744073709551615
} Quick test in NodeJS. > JSON.parse("{\"n\": 18446744073709551615}")
{ large_number: 18446744073709552000 } Python doesn't has this problem since it has proper large number support by default: import json
json.loads('{"n": 18446744073709551615}')
{'n': 18446744073709551615} Therefore we can only safely represent these as string in JSON {
"n": "18446744073709551615"
} And if needed a Javascript application can calculate with them as The Javascript engine in deCONZ doesn't support BigInt yet but that can be added if needed. But back to However an actual safe string representation already exists for every lightNode->parentResource()->item(RAttrUniqueId)->toString() // e.g. "00:0b:57:ff:fe:26:56:80" However personally I don't see any value in exposing this since we already have this with the sub-resource |
Happy to make
Yes, as mentioned above, there are only a few u64 |
Does the issue really belong here?
Is there already an existing issue for this?
Describe the bug
I see negative values reported for
extaddress
, for instance:Of course, the Mac Address is a 64-bit unsigned integer.
RAttrExtAddress
is defined as such alright:deconz-rest-plugin/resource.cpp
Line 389 in 8ae69a9
However, internally
ResourceItem
stores numeric values asqint64
andResourceItem::toNumber()
also returns aqint64
.Steps to reproduce the behavior
Need PR #7979 to show
extaddress
in the API, then request alights
orsensors
resource for a device with a MAC address of 80:00:00:00:00:00:00 or greater.Expected behavior
extaddress
should be shown as unsigned number.Screenshots
No response
Environment
lightToMap()
andsensorToMap()
#7979.deCONZ Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: