Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add functional test case about how use special word valueas a name of attribute #1668

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AlvaroVega
Copy link
Member

@AlvaroVega AlvaroVega commented Nov 8, 2024

IMHO this test case demostrates which #1660 is working

@AlvaroVega AlvaroVega changed the title add test case add functional test case about how use special word valueas a name of attribute Nov 8, 2024
@AlvaroVega AlvaroVega requested a review from fgalan November 8, 2024 09:27
@fgalan
Copy link
Member

fgalan commented Nov 8, 2024

CC @tzzed @GuillaumeOd what do you think?

@GuillaumeOd
Copy link

GuillaumeOd commented Nov 12, 2024

Thanks for the test, @AlvaroVega. It’s working fine on my end as well. However, in some cases, we’re sending attr_name as a JSON value instead of object_id.

For example:

{
    "a": false,
    "value": 10
}

As expected, this change causes the test to fail. It doesn’t seem to be related to the "value" string itself, as I tested with other random words, and it still doesn’t work. From what I understand, this change appears to remove the capability to update a device attribute by name.

What are your thoughts?

@AlvaroVega
Copy link
Member Author

Then maybe you can define your attribute with a conditional expression:
"expression": "value? value : t"

@GuillaumeOd
Copy link

GuillaumeOd commented Nov 12, 2024

I suppose the core question from my previous comment is this: should we only be updating an attribute using its object_id, or should we still have the option to update it by its name, as was possible before this change ?

@AlvaroVega
Copy link
Member Author

I suppose the core question from my previous comment is this: should we only be updating an attribute using its object_id, or should we still have the option to update it by its name, as was possible before this change ?

measures should use object_id

@GuillaumeOd
Copy link

The doc is still showing examples of measures sent by attribute names.

https://iotagent-node-lib.readthedocs.io/en/latest/api.html

You can find examples at "Multimeasure support" and "Measurement transformation" sections.

Please consider the test added to my PR and reproduce it in local without my fix in order to demonstrate this.

@AlvaroVega
Copy link
Member Author

The doc is still showing examples of measures sent by attribute names.

https://iotagent-node-lib.readthedocs.io/en/latest/api.html

Regarding with Device to NGSI Mapping section:

  • object_id (optional): name of the attribute as coming from the device.
  • name (mandatory): ID of the attribute in the target entity in the Context Broker. Note that id and type are not valid attribute names at Context Broker. Thus, although a measure named id or type will not break the IoT Agent, they are silently ignored and never progress toward Context Broker entities.

@tzzed
Copy link

tzzed commented Nov 19, 2024

@AlvaroVega I am not sure to understand what you say.
Do you mean that if the entity contains an attribue:

temperature: {
            value: 10,
            type: 'Integer',
            creDate: 1730990416.543879,
            modDate: 1730990416.543879,
            mdNames: []
        },

the iotagent cannot send

{
 "temperature": 42
}

What about real life? you mean only the oid works? What about the previous behavior?

@AlvaroVega
Copy link
Member Author

AlvaroVega commented Nov 19, 2024

What about real life? you mean only the oid works? What about the previous behavior?

Of course you can send as a measure an attribute name which will be part of entity, but then do not include it in device attribute mapping, like ac3f194, or simply put the same name in object_id and name attribute, or even more do not define object_id, just name attribute 10167df

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants