What does "invalid NUMBER type" mean?

I’m POSTing to the smart things REST API with the below body and I get back the below 422 error response. Can someone please let me know what “invalid NUMBER type” means and how to get “setSwitchLevel” to work?

Request:

https://api.smartthings.com/v1/devices/**UUID_MASKED**/commands

{"commands":[{"component":"main","capability":"switchLevel","command":"setLevel","arguments":[{"level":1}]}]}

Response:

{"requestId":"E8D5E7D9-118A-43A6-842A-C446728AE5F1","error":{"code":"ConstraintViolationError","target":null,"message":"The request is malformed.","details":[{"code":"UnprocessableEntityError","target":"[0].arguments.[0]","message":"invalid NUMBER type","details":[]}]}}

No need to specify the argument name:

{
  "commands": [
    {
      "component": "main",
      "capability": "switchLevel",
      "command": "setLevel",
      "arguments": [
        20
      ]
    }
  ]
}
1 Like

Thank you!

1 Like

Could you tell me what the format for this light to set the level in a similar way to the above please ?

The above in the previous post works fine for normal bulbs but for colour ones the switchLevel is different ?

Tried this but get a 422 error:

{“commands”:[{“component”: “main”, “capability”: “switchLevel”, “command”: “setLevel”, “arguments”: [{‘level’: {‘unit’: ‘%’,‘value’: 99}}]}]}`

Thanks

RGBW bulb status:

  u'components': {
    u'main': {
      u'powerMeter': {
        u'power': {
          u'value': None
        }
      },
      u'refresh': {
        
      },
      u'switch': {
        u'switch': {
          u'value': u'on'
        }
      },
      u'colorControl': {
        u'color': {
          u'value': u'#FFFFFF'
        },
        u'hue': {
          u'value': 0.0
        },
        u'saturation': {
          u'value': 0.0
        }
      },
      u'polling': {
        
      },
      u'actuator': {
        
      },
      u'configuration': {
        
      },
      u'sensor': {
        
      },
      u'switchLevel': {
        u'level': {
          u'unit': u'%',
          u'value': 99
        }
      }
    }
  }
}

Actually it does work with just one argument as above !

Can’t get colorControl to work though, is this correct ?

{"commands":[{"component": "main", "capability": "colorControl", "command": "color", "arguments": ['#00ff00']}]}

getting a 422 response

Tried this:

{"commands":[{"component": "main", "capability": "colorControl", "command": "setColor", "arguments": [{'color': {'value': '#00FF00'},'hue': {'value': 33.33333333},'saturation': {'value': 100}}]}]}

get no error but it turns the bulb off.

This appears in the IDE log:

setColor: [saturation:[value:100], color:[value:#00FF00], hue:[value:33.33333333]]