Hi,
So I'm working on a project that makes use of the Maker API to scrape data from sensors so I can graph the data. This is mostly fine and a lot of the data presented is self explanatory, or has a decent enough explanation at docs.hubitat.com.
However, the attributes
map returned for devices seems a little strange. The dataType
and values
keys don't seem to mean anything.
For example, here we have a light bulb:
"attributes": {
"colorTemperature": null,
"dataType": "ENUM",
"values": [
"on",
"off"
],
"level": "100",
"switch": "off",
"colorName": null
},
OK, great, the dataType
seems to tell us that values
is an ENUM
and those values are clearly the values that switch
can be. But there are also colorName
, colorTemperature
, and level
, why no information on what those could be?
Next, we look at an outlet:
"attributes": {
"energy": "0.134",
"dataType": "NUMBER",
"values": null,
"power": "0",
"switch": "off",
"checkInterval": "720"
},
This time dataType
is NUMBER
and values
is null
. This appears to be useless. We have a lot of number values here, which was it talking about? And why is the switch
ENUM
no longer mentioned anywhere?
Off we go to the docs looking for an explanation of this and we find the Attribute Object, but there's no real explanation for what the Maker API is returning.
It feels like the attributes
map in its current form may be merging a bunch of other attribute maps together to generate its content, meaning we end up with the values
and dataType
from one of our attributes, but we don't know which, making them essentially random and useless.
Would the attributes
map perhaps be improved if it was exposed as:
"attributes": {
"switch": {
"dataType": "ENUM",
"values": [
"on",
"off"
],
"value": "on"
},
"energy": {
"dataType": "NUMBER",
"values": null,
"value": "0.134"
}
}
This tells you the precise dataType
, values
(if possible), and value
for each attribute
in an unambiguous way.
I may also be looking at this completely incorrectly and there is some logic behind which attribute dataType
and values
correspond to.
So, does anyone know how those values work, or know which part of the documentation I've missed?
Thanks,