Noticed a couple of inconsistencies when working with the Maker API.
When querying a specific device details with the Get Device Info
http://xxx.xxx.xxx.xxx/apps/api/XXX/devices/[Device ID]?access_token=
the JSON returned for "currentValue" temperature and humidity are encoded as JSON numbers, while the voltage is wrapped as a string. No units are returned.
{
"id":"154",
"name":"Temp Sensor",
"label":"Temp Sensor",
"type":"SensorPush Sensor",
"room":null,
"attributes":[
{
"name":"humidity",
"currentValue":59.5, <---- value is number
"dataType":"NUMBER"
},
{
"name":"temperature",
"currentValue":-12.3,
"dataType":"NUMBER"
},
{
"name":"batteryVoltage",
"currentValue":"2.25",
"dataType":"STRING"
}
]
}
Compare to the POST back message for the same device:
- Units of measure ARE returned
- The value element is always a string
{
"content":{
"name":"humidity",
"value":"59.5", <----- value is text
"displayName":"Temp Sensor",
"deviceId":"154",
"descriptionText":"Temp Sensor: humidity is 59.5%",
"unit":"%",
"type":null,
"data":null
}
}
Questions:
- As the system knows the data types, why are the POST JSON "value" elements always encoded as text?
- Why no unit element in the Get Device Info for current attributes? I notice the *current state *attributes on the device details page doesn't show the units appended, but the events do. Shouldn't units be reflected in the current state attributes?