Q:

Why do attributes type change from float to number?

I've noticed that when I register entities with some 'float' attributes in Orion, after some updates the type is changed to 'number' instead of 'float'.
For example:
{ "id":"my_entity", 
  "type":"entity_type",
  "attr1":{
      "type":"float",
      "value":"0.54",
      "metadata":{}},
  "attr2":{
      "type":"Number",
      "value":44.3,
      "metadata":{}}}]

In this case, when my_entity was registered, both types of attributes were 'float'. When some update was made in the value of the attr2, its type was changed to 'Number'. Is this the correct behavior?

A:

I think this is due to default typing, as described in the "Partial Representations" section in the NGSIv2 spec:

Attribute/metadata type may be omitted in requests. When omitted in attribute/metadata creation or in update operations, a default is used for the type depending on the value:

If value is a string, then type Text is used
If value is a number, then type Number is used.
If value is a boolean, then type Boolean is used.
If value is an object or array, then StructuredValue is used.
If value is null, then None is used.

Thus, probably you are updating your attribute using the following (o a similar) API operation:
PUT /v2/entities/my_entity/attrs/attr2

{
  "value": 44.3
}

and type omission in that payload is triggering the default typing feature.
Basically, there are two solutions to this:

Use type in your attribute update operation:
PUT /v2/entities/my_entity/attrs/attr2

{
  "type": "float",
  "value": 44.3
}

Use the attribute value update operation (which doesn't touch type or metadata):
PUT /v2/entities/my_entity/attrs/attr2/value

44.3

