MakerAPI: some way to distinguish between different Connector variable types (ie: boolean, number, decimal, string)

I'm offering a way to update a connector variable in my dashboard app but running into a minor issue.. how to know what data type the variable is. For example, if I knew it was a number type, I could just show the number keypad and not allow strings to be set.

So, first question is - is there already a way to distinguish between different Connector variable types (ie: boolean, number, decimal, string)?

I don't see one looking at the device detail response (example below)

If not, can a way be added? I would have thought "dataType" : "STRING" would have been the ideal way to convey this (ie: replace STRING with NUMBER) but I can see how that might brake other apps.. but, just wanted to get the question out there to see if others were wondering it too..

 133) GET http://192.168.0.210/apps/api/38/devices/694
 << 133) 305b, DATA:
{
    "id" : "694",
    "name" : "DecimalVariable",
    "label" : "DecimalVariable",
    "type" : "Connector Variable",
    "attributes" : 
    [
        
        {
            "name" : "variable",
            "currentValue" : "45.12",
            "dataType" : "STRING"
        }
    ],
    "capabilities" : 
    [
        "Actuator",
        "Variable",
        
        {
            "attributes" : 
            [
                
                {
                    "name" : "variable",
                    "dataType" : null
                }
            ]
        },
        "Sensor"
    ],
    "commands" : 
    [
        "parse",
        "setVariable"
    ]
}

The connectors are an implementation of capability Variable. All attributes are stored as strings, but the input format for them are limited by constraints.

Driver Definition

capability "Variable"

Attributes

variable - STRING

Commands

setVariable(valueToSet)

valueToSet required (STRING)

1 Like

Is there a way to know what 'constraints' are used for a given variable? Is that only known internally or is there some way it's exposed via MakerAPI so I can give the user a more specific type of entry (ie: just numbers)

It shows up as part of the map for the command setVariable but I don’t think MakerApi exposes it:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.