MakerAPI request: request param to ignore 'null' value attributes to reduce payload size

Hi,

I'm using the MakerAPI to fetch device info and noticed that it returns all attributes regardless if there's a 'null' value set or not. While maybe some devs are interested in just knowing that a device has an attribute or not - I would argue there's not much value in getting a null attribute and would rather not have it passed back at all to save payload size.

        {
            "name" : "Battery Voltage Interval",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },

I'm not requesting that MakerAPI make any default changes -- but what about a request param to ignore these null attributes?

Here's an example of 1 device response in the MakerAPI:

http://192.168.0.202/apps/api/38/devices/334
{
    "id" : "359",
    "name" : "Camera-88951",
    "label" : "front door",
    "attributes" : 
    [
        
        {
            "name" : "AC Power",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Account",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Account ID",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Alert Interval",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Alert Repeat",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Alert Tone Enable",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Alert Tone Volume",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Arm String",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Armed",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Auto Arm By Geo",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Auto Arm By Time",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Auto Test",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Backfill In Progress",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Battery Alarm Enable",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Battery Alert Account",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Battery Alert Count",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Battery Alert Status",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Battery Check Time",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Battery Number",
            "currentValue" : 3,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Battery Status",
            "currentValue" : "ok",
            "dataType" : "STRING"
        },
        
        {
            "name" : "Battery Voltage",
            "currentValue" : 164,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Battery Voltage Hysteresis",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Battery Voltage Interval",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Battery VoltageThreshold",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Busy",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Buzzer On",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Camera Error",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Camera ID",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Camera Key",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Camera Seq",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Clip Bitrate",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Clip Max Length",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Clip Rate",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Clip Seconds",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Clip Warning Threshold",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Continue Warning",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Created",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "DHCP Failure Count",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Daylight Savings Time",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Deleted",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Dev 1",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Dev 2",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Dev 3",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Early Notification",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Early Notification Compatible",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Early PIR Compatible",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Early Termination",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Early Termination Supported",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Enabled",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Encryption Key",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Error Codes",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "FW Git Hash",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Feature Plan ID",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Firmware Version",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Flip Image",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Flip Video",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Flip Video Compatible",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "ID",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "IPv",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Illuminator Duration",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Illuminator Enable",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Illuminator Intensity",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Invert Image",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Issues",
            "currentValue" : "[]",
            "dataType" : "STRING"
        },
        
        {
            "name" : "Join Available",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Join State",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "LFR 108 Wakeups",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "LFR Alert Count",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "LFR Channel",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "LFR Frequency",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "LFR Strength",
            "currentValue" : 5,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "LFR Sync Interval",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "LFR TB Wakeups",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Last Activity",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Last Backfill Completed",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Last Backup Completed",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Last Backup Started",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Last Command ID",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Last HB",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Last LFR Alert",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Last Snapshot Event",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Last Temp Alert",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Last Wifi Alert",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Lifetime Count",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Lifetime Duration",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Light Sensor CH0",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Light Sensor CH1",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Light Sensor Data New",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Light Sensor Data Valid",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "LiveView Continue Interval",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "LiveView Duration",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "LiveView Enabled",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "LiveView Mode",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "LiveView RSTP",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "LiveView Rate",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "LiveView Seconds",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Liveview Bitrate",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Local Storage Compatible",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Local Storage Enabled",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Local Storage Status",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "MAC Address",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "MFG Main Range",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "MFG Main Type",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "MFG Mez Range",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Manufacturer Mez Type",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Max Resolution",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Media ID",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Motion Detection Enabled",
            "currentValue" : "true",
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Motion Regions",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Motion Regions Compatible",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Motion Sensitivity",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Name",
            "currentValue" : "front door",
            "dataType" : "STRING"
        },
        
        {
            "name" : "Network ID",
            "currentValue" : 39640,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Network Key",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Network Origin",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "NetworkID",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "New Command",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Night Vision Exposure",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Night Vision Exposure Compatible",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "OS Version",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Offline Alert Count",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Onboarded",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Options",
            "currentValue" : null,
            "dataType" : "MAP"
        },
        
        {
            "name" : "PIR Rejections",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Ping Interval",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Privacy Zones Compatible",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Record Audio",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Record Audio Enable",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Retry Count",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "SM Backup Enabled",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Serial",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Server",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Siren Enable",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Siren Volume",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Snapshot Compatible",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Snapshot Enabled",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Snapshot Period Minutes Options",
            "currentValue" : null,
            "dataType" : "LIST"
        },
        
        {
            "name" : "Socket Failure Count",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Status",
            "currentValue" : "done",
            "dataType" : "STRING"
        },
        
        {
            "name" : "Status",
            "currentValue" : "done",
            "dataType" : "STRING"
        },
        
        {
            "name" : "Storage Total",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Storage Used",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Submit Logs",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Sync Module Error",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Sync Module ID",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Table Update Sequence",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Temp Adjust",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Temp Alarm Enable",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Temp Alert State",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Temp Alert Status",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Temp Alerts Enabled",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Temp Hysteresis",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Temp Interval",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Temp Max",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Temp Min",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Temperature Alert Count",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Thumbnail",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Thumbnail File",
            "currentValue" : "fw_7.96__Zi7psW4H_2020_09_18__12_44PM.jpg",
            "dataType" : "STRING"
        },
        
        {
            "name" : "Thumbnail Image",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Time 108 Boot",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Time DHCP Lease",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Time DNS Resolve",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Time First Video",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Time WLAN Connect",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Time Zone",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Total 108 Wakeups",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Total TB Wakeups",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Type",
            "currentValue" : "xt2",
            "dataType" : "STRING"
        },
        
        {
            "name" : "Unit Number",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Updated",
            "currentValue" : "2020-09-28T14:27:59+00:00",
            "dataType" : "STRING"
        },
        
        {
            "name" : "Usage",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Usage Rate",
            "currentValue" : "false",
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Video Description",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Video History Count",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Video Length",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Video Quality",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "Video Recording Enable",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Video Recording Optional",
            "currentValue" : null,
            "dataType" : "BOOL"
        },
        
        {
            "name" : "Video hz",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "WiFi Connect Failure Count",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "WiFi Strength",
            "currentValue" : -53,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "WiFi Timeout",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "Wifi Alert Count",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "battery",
            "currentValue" : null,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "html",
            "currentValue" : null,
            "dataType" : "STRING"
        },
        
        {
            "name" : "temperature",
            "currentValue" : 77,
            "dataType" : "NUMBER"
        },
        
        {
            "name" : "temperature",
            "currentValue" : 77,
            "dataType" : "NUMBER"
        }
    ],
    "capabilities" : 
    [
        "TemperatureMeasurement",
        
        {
            "attributes" : 
            [
                
                {
                    "name" : "temperature",
                    "dataType" : null
                }
            ]
        },
        "Battery",
        
        {
            "attributes" : 
            [
                
                {
                    "name" : "battery",
                    "dataType" : null
                }
            ]
        },
        "Sensor",
        "Actuator"
    ],
    "commands" : 
    [
        "ArmSystem",
        "DisableMotionDetection",
        "DisarmSystem",
        "EnableMotionDetection"
    ]
}

Honestly in this case you might want to have a look at the driver, personally I question the usefulness of the vast majority of these attributes, however beyond that they shouldn't be null in the first place.

fair enough.. this driver is still a WIP so it may well change here. I have a few other drivers that also have a lot of null attributes but I noticed they're also all custom drivers too

thanks for the quick reply!!

@mike.maxwell -- totally unrelated question but I just found out about /devices/* and that it works a lot faster than /devices/all. I was just curious if there's any caveats or warnings for using /devices/* vs iterating over all the devices and fetching them individually.

a quick review of the code would seem to indicate that /devices/all returns all the devices in your system vs /devices/* returns all the devices that you selected...

2 Likes

The one time I"ve seen this "null" value used that is helpful is with Battery operated devices. Some devices (e.g., sensors) can be operated on Battery or USB, so they will expose the Battery Capability. It seems that in (at least) some of those devices, if the device is being used under USB power, the Battery attribute gets set to "null" which lets you know the Battery isn't in use -- i.e., its USB powered. I've been using that in a homebridge plugin (homebridge-hubitat - npm that I'm adapting for Hubitat from one I previously wrote for HomeSeer) -- this lets me know whether I should configure iOS to report on battery status for a device.

One (namely me) could argue that Maker API shouldn't be returning info for any device that isn't selected in Maker API...

Regardless, devices/all returns malformed and mangled json too often to be of any use anyway (versus devices/* - devices/all is better than nothing, just not better than devices/*). It should really be deprecated and removed.

1 Like