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

Question: Define an HTTP Protocol to Support Lazy Attributes. #574

Open
jason-fox opened this issue Aug 4, 2022 · 3 comments
Open

Question: Define an HTTP Protocol to Support Lazy Attributes. #574

jason-fox opened this issue Aug 4, 2022 · 3 comments

Comments

@jason-fox
Copy link
Contributor

Currently when I provision a device like this using the Ultralight or JSON IoT Agent:

{
     "endpoint": "http://iot-sensors/iot/lamp001",
...      
     "commands": [ 
        {"name": "on","type": "command"},
        {"name": "off","type": "command"}
     ],
     "lazy": [
        {"object_id": "b", "name": "batteryLevel", "type":"Number",
          "metadata": {"unitCode": {"type": "Text","value": "C62"}}
        }
     ],
     "attributes": [
        {"object_id": "s", "name": "state", "type":"Text"},
        {"object_id": "l", "name": "luminosity", "type":"Integer",
          "metadata": {"unitCode": {"type": "Text","value": "CDL"}}
        }
     ]
   }

I can successfully send HTTP Commands to my device using the endpoint http://iot-sensors/iot/lamp001, however retrieving the entity the lazy attribute is always blank (yes, I know #23 is still open). If I had provisioned the same device using the OPC-UA IoT Agent, it would make an OPC request for the lazy attribute to the OPC-UA server.

Is there any good reason why at least the HTTP Binding couldn't have a queryHandler (similar to the existing commandHandler) to make a GET request on <endpoint>/<lazy-attribute> ?

So in this case a GET http://orion:1026/v2/entities/Lamp:001?attrs=batteryLevel
should result in a GET http://iot-sensors/iot/lamp001/b (where b is the object_id for `batteryLevel). correct?

It doesn't make sense to add an equivalent for MQTT or AMPQ because message queues are not synchronous.

@jason-fox
Copy link
Contributor Author

jason-fox commented Aug 4, 2022

The alternative would be to use the same endpoint and ultralight syntax as the existing command:

So in this case a GET http://orion:1026/v2/entities/Lamp:001?attrs=batteryLevel
should result in a POST http://iot-sensors/iot/lamp001/ with payload Lamp:001@b (where b is the object_id for batteryLevel).

ultralight syntax normally being <id>@<attribute>|<value>...

@jason-fox
Copy link
Contributor Author

The equivalent payload in JSON syntax:

So in this case a GET http://orion:1026/v2/entities/Lamp:001?attrs=batteryLevel
should result in a POST http://iot-sensors/iot/lamp001/ with payload {"b": null} (where b is the object_id for batteryLevel).

JSON syntax normally being{"<attribute>": <value>...}

@mapedraza
Copy link
Collaborator

As you noticed, the iotagent-node-lib supports the Lazy Atttributes but they are not implemented in some IoT agents (like UL and JSON).

As you described, using a command would have the same behavior that a lazy attribute. The difference between them is Lazy Attributes are synchronous and commands asynchronous. We are using commands for retrieving information from devices for that reason.

Implementing Lazy Attributes in those agents is an option. The other options is to use the commands for retrieving the data

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

No branches or pull requests

2 participants