Giter Club home page Giter Club logo

tutorials.iot-agent's Introduction

FIWARE Banner

FIWARE IoT Agents License: MIT Support badge UltraLight 2.0

These tutorials introduce the concept of an IoT Agent and wires up the dummy UltraLight 2.0 IoT devices created in the previous tutorial so that measurements can be read and commands can be sent using NGSI-v2 or NGSI-LD requests sent to the Context Broker.

The tutorial uses cUrl commands throughout, but is also available as Postman documentation.

Start-Up

NGSI-v2 Smart Supermarket

NGSI-v2 offers JSON based interoperability used in individual Smart Systems. To run this tutorial with NGSI-v2, use the NGSI-v2 branch.

git clone https://github.com/FIWARE/tutorials.IoT-Agent.git
cd tutorials.IoT-Agent
git checkout NGSI-v2

./services create
./services start
NGSI v2 πŸ“š Documentation Postman Collection

NGSI-LD Smart Farm

NGSI-LD offers JSON-LD based interoperability used for Federations and Data Spaces. To run this tutorial with NGSI-LD, use the NGSI-LD branch.

git clone https://github.com/FIWARE/tutorials.IoT-Agent.git
cd tutorials.IoT-Agent
git checkout NGSI-LD

./services create
./services start
NGSI LD πŸ“š Documentation Postman Collection

License

MIT Β© 2018-2024 FIWARE Foundation e.V.

tutorials.iot-agent's People

Contributors

actions-user avatar fisuda avatar jason-fox avatar walterwootz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tutorials.iot-agent's Issues

Iot-Agent with NGSI-LD - @context

Hello all,
I have questions regarding the use of the Iot-Agent with NGSI-LD.

I will first explain the use case and then get to my questions. The attached sketch should help in understanding.

I use the IoT-agent for provisioning data from different sources. Each data source has its own naming of attributes, but also references the same models (URLs).

In the Context Broker, there should be no difference between the names, the same URLs should be used.

I wanted to create a separate context file for each data source that contains the respective mapping.

In the docker-compose.yml file of the IoT-agent, IOTA_JSON_LD_CONTEXT can be used to specify a context file to use. This specification is used to register entities in context brokers with the attribute "@ context".

Two questions came up:

  1. is it possible to use more than one context file when deploying via the IoT-Agent?
    If this is not possible, would I need to create a union with each file for the IoT-Agent so that the URL mapping of the different data sources works consistently? Or can I specify a specific context file during provisioning?

  2. when I provision and change this file via a web service, this change does not seem to be automatically detected by the IoT-Agent. Is there a way to push this update?

image

Issue at the IoT Agent tutorial page

Hi, I've been following the tutorial step by step, now I found that this command:
https://github.com/Fiware/tutorials.IoT-Agent/tree/e871f9cb22580e8540159fd56091fb91be061e29#six-request
Is throwing a 400 error (Bad Request):

HTTP/1.1 400 Bad Request
X-Powered-By: Express
Fiware-Correlator: 4a43cf97-96a5-4662-bf60-40383593af34
Content-Type: application/json; charset=utf-8
Content-Length: 255
Date: Mon, 22 Oct 2018 11:30:53 GMT
Connection: keep-alive

{"name":"BAD_REQUEST","message":"Request error connecting to the Context Broker: {\"code\":\"400\",\"reasonPhrase\":\"Bad Request\",\"details\":\"JSON Parse Error: unknown field: /contextRegistrations/contextRegistration/attributes/attribute/isDomain\"}"}

Any suggestions? Thanks!

IoT Agent tutorial - Bad Request

Going through the IoT Agent tutorial (I'm resending this ticket since I don't see it in the open list).
When calling the command to connect an actuator to the IoT Agent, I get a Bad Request error.
The command:
curl -iX POST \ 'http://localhost:4041/iot/devices' \ -H 'Content-Type: application/json' \ -H 'fiware-service: openiot' \ -H 'fiware-servicepath: /' \ -d '{ "devices": [ { "device_id": "bell001", "entity_name": "urn:ngsi-ld:Bell:001", "entity_type": "Bell", "protocol": "PDI-IoTA-UltraLight", "transport": "HTTP", "endpoint": "http://iot-sensors:3001/iot/bell001", "commands": [ { "name": "ring", "type": "command" } ], "static_attributes": [ {"name":"refStore", "type": "Relationship","value": "urn:ngsi-ld:Store:001"} ] } ] } '

And this is the error

`HTTP/1.1 400 Bad Request
X-Powered-By: Express
Fiware-Correlator: cd34174d-a2ad-4214-98d7-a967d301fac8
Content-Type: application/json; charset=utf-8
Content-Length: 255
Date: Mon, 22 Oct 2018 11:45:55 GMT
Connection: keep-alive

{"name":"BAD_REQUEST","message":"Request error connecting to the Context Broker: {"code":"400","reasonPhrase":"Bad Request","details":"JSON Parse Error: unknown field: /contextRegistrations/contextRegistration/attributes/attribute/isDomain"}"}`

Any suggestions?

Register IoT Agent

Hi,
I have a customer who'd like to make use of the FIWARE platform.

I personally come from a background of AWS and Azure and (perhaps wrongly) assumed an IoT Agent is equivalent of a "Thing" (AWS) or "Device"(Azure). In other words, this would represent the device connecting to the Context Broker.

-If this is the case, how do I provision new IoT Agents, accepting and providing keys and tokens for agents?

IOT Agent for Orion-LD

Hello Team,

I am using Orion-ld for my company's POC purpose. For the same, I used IOT agent from GITHUB link below:

https://github.com/FIWARE/tutorials.IoT-Agent.git

This IOT Agent code works fine with Orion V2 broker but gives below error with Orion-LD while registering Lamp or other actuator devices:

=================================================================================================

time=2020-08-10T07:07:21.672Z | lvl=DEBUG | corr=7591bead-a4b8-421c-a8b9-3c6a3c7da7ae | trans=7591bead-a4b8-421c-a8b9-3c6a3c7da7ae | op=IoTAgentNGSI.MongoDBGroupRegister | srv=n/a | subsrv=n/a | msg=Looking for group params ["type"] with queryObj {"type":"Lamp"} | comp=IoTAgent
time=2020-08-10T07:07:21.673Z | lvl=DEBUG | corr=7591bead-a4b8-421c-a8b9-3c6a3c7da7ae | trans=7591bead-a4b8-421c-a8b9-3c6a3c7da7ae | op=IoTAgentNGSI.MongoDBGroupRegister | srv=n/a | subsrv=n/a | msg=Device group for fields [["type"]] not found: [{"type":"Lamp"}] | comp=IoTAgent
time=2020-08-10T07:07:21.674Z | lvl=DEBUG | corr=7591bead-a4b8-421c-a8b9-3c6a3c7da7ae | trans=7591bead-a4b8-421c-a8b9-3c6a3c7da7ae | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=error {"name":"DEVICE_GROUP_NOT_FOUND","message":"Couldn\t find device group","code":404} in get group device | comp=IoTAgent
time=2020-08-10T07:07:21.677Z | lvl=ERROR | corr=7591bead-a4b8-421c-a8b9-3c6a3c7da7ae | trans=7591bead-a4b8-421c-a8b9-3c6a3c7da7ae | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=Registration error connecting to the Context Broker: 501 | comp=IoTAgent
time=2020-08-10T07:07:21.677Z | lvl=DEBUG | corr=7591bead-a4b8-421c-a8b9-3c6a3c7da7ae | trans=7591bead-a4b8-421c-a8b9-3c6a3c7da7ae | op=IoTAgentNGSI.DeviceProvisioning | srv=n/a | subsrv=n/a | msg=Device provisioning failed due to the following error:  | comp=IoTAgent Request error connecting to the Context Broker: 501
time=2020-08-10T07:07:21.677Z | lvl=DEBUG | corr=7591bead-a4b8-421c-a8b9-3c6a3c7da7ae | trans=7591bead-a4b8-421c-a8b9-3c6a3c7da7ae | op=IoTAgentNGSI.GenericMiddlewares | srv=n/a | subsrv=n/a | msg=Error [BAD_REQUEST] handling request: Request error connecting to the Context Broker: 501 | comp=IoTAgent
=======================================================================================================

Please let me know, if Fiware already have IOT agent code available for Orion-LD or I need to use any different setting in docker-compose.yml file for environment.

Thanks & Regards, Sunil Kumar

There are some typos

Hello @jason-fox

  1. typo 'FIWARE 201: Provisioning an IoT Agent' in topics
    s/201/202/

  2. typo 'by the from the Context Broker' in 'Southbound Traffic (Commands)' section.
    HTTP requests generated by the from the Context Broker and passed downwards towards an IoT device (via an IoT agent) are known as southbound traffic.

p.s. I will issue a PR of Japanese document on this weekend again.

Redundant registrations after provisioning

In Enabling Context Broker Commands part, the doc says registration process is required to invoke the command.
However, I found that the registration is automatically created during provisioning step.
After I provisioned bell001 and door001, corresponding registrations also exist in the DB, and I was able to ring the bell and open the door without any additional requests.

In short, '13 Request:' works without '12 Request:'

The only difference is that providingApplication is set to http://iot-agent:4041 in auto-added one, while its value is http://orion:1026/v1 in manually requested one.
(expiration and description is also different though)

Can't start all the services

I encountered the following problem while trying to start the services

Orion is the context broker
IoT-Agent is configured for the UltraLight Protocol
Context-Provider acts as a series of dummy IoT Sensors over HTTP

Creating db-mongo ... done
Creating context-provider ... done
Creating fiware-iot-agent ...
Creating fiware-orion ... error

ERROR: for fiware-orion Cannot create container for service orion: Conflict. The container name "/fiware-orion" is already in use by container "3b4b8e6a67831f7Creating fiware-iot-agent ... error
e) that container to be able to reuse that name.

ERROR: for fiware-iot-agent Cannot start service iot-agent: driver failed programming external connectivity on endpoint fiware-iot-agent (affe4af16b6c4204d9def853736c091fcb80cb4c2fae1ea6698006052b7ce8c6): Error starting userland proxy: listen tcp 0.0.0.0:4041: bind: address already in use

ERROR: for orion Cannot create container for service orion: Conflict. The container name "/fiware-orion" is already in use by container "3b4b8e6a67831f7e3faea28297d6306814d846856fefa597a0e28f75445e8a15". You have to remove (or rename) that container to be able to reuse that name.

ERROR: for iot-agent Cannot start service iot-agent: driver failed programming external connectivity on endpoint fiware-iot-agent (affe4af16b6c4204d9def853736c091fcb80cb4c2fae1ea6698006052b7ce8c6): Error starting userland proxy: listen tcp 0.0.0.0:4041: bind: address already in use
ERROR: Encountered errors while bringing up the project.

Can’t[Provisioning a Smart Lamp]

Execution of the tutorial command results in an error.

$ curl -iX POST \
>   'http://localhost:4041/iot/devices' \
>   -H 'Content-Type: application/json' \
>   -H 'fiware-service: openiot' \
>   -H 'fiware-servicepath: /' \
>   -d '{
>   "devices": [
>     {
>       "device_id": "lamp001",
>       "entity_name": "urn:ngsi-ld:Lamp:001",
>       "entity_type": "Lamp",
>       "protocol": "PDI-IoTA-UltraLight",
>       "transport": "HTTP",
>       "endpoint": "http://iot-sensors:3001/iot/lamp001",
>       "commands": [
>         {"name": "on","type": "command"},
>         {"name": "off","type": "command"}
>        ],
>        "attributes": [
>         {"object_id": "s", "name": "state", "type":"Text"},
>         {"object_id": "l", "name": "luminosity", "type":"Integer"}
>        ],
>        "static_attributes": [
>          {"name":"refStore", "type": "Relationship","value": "urn:ngsi-ld:Store:001"}
>       ]
>     }
>   ]
> }
> '
HTTP/1.1 409 Conflict
X-Powered-By: Express
Fiware-Correlator: e2dfb1c9-f8fb-458c-8f53-ebc569e4fa87
Content-Type: application/json; charset=utf-8
Content-Length: 108
ETag: W/"6c-MXV0ASHmZcVgSm+giF5KNzT8oKg"
Date: Thu, 29 Dec 2022 13:41:59 GMT
Connection: keep-alive
Keep-Alive: timeout=5

{"name":"DUPLICATE_DEVICE_ID","message":"A device with the same pair (Service, DeviceId) was found:lamp001"}

The details of lamp001 at this time are as follows.

$ curl -iX GET \
>   'http://localhost:4041/iot/devices/lamp001' \
>   -H 'Content-Type: application/json' \
>   -H 'fiware-service: openiot' \
>   -H 'fiware-servicepath: /'
HTTP/1.1 200 OK
X-Powered-By: Express
Fiware-Correlator: 9137758e-ffec-4183-b2cb-64764bac4582
Content-Type: application/json; charset=utf-8
Content-Length: 170
ETag: W/"aa-DtkbAvlQAzPkTzVDNEWEFDN2uS0"
Date: Thu, 29 Dec 2022 14:23:32 GMT
Connection: keep-alive
Keep-Alive: timeout=5

{"device_id":"lamp001","service":"openiot","service_path":"/","entity_name":"Thing:lamp001","entity_type":"Thing","transport":"HTTP","commands":[],"static_attributes":[]}

I deleted lamp001 and tried again but got the same error.

$ curl -iX DELETE \
>   'http://localhost:4041/iot/devices/lamp001' \
>   -H 'fiware-service: openiot' \
>   -H 'fiware-servicepath: /'
HTTP/1.1 204 No Content
X-Powered-By: Express
Fiware-Correlator: 13850b76-210f-4fea-b43f-cd6922988d06
Date: Thu, 29 Dec 2022 14:21:27 GMT
Connection: keep-alive
Keep-Alive: timeout=5
-----
$ curl -iX GET \
>   'http://localhost:4041/iot/devices/lamp001' \
>   -H 'Content-Type: application/json' \
>   -H 'fiware-service: openiot' \
>   -H 'fiware-servicepath: /'
HTTP/1.1 404 Not Found
X-Powered-By: Express
Fiware-Correlator: 7969f9a8-8126-42c3-adf9-4e6ab03075c7
Content-Type: application/json; charset=utf-8
Content-Length: 75
ETag: W/"4b-K4b3wKcdA3xs//EOZUi47GwR6k0"
Date: Thu, 29 Dec 2022 14:21:52 GMT
Connection: keep-alive
Keep-Alive: timeout=5

{"name":"DEVICE_NOT_FOUND","message":"No device was found with id:lamp001"}

Please let me know how I can avoid this.

Added 2023/1/4:
I don't know if it's directly related, but the container log has the following error.

{"log":"time=2023-01-04T14:15:51.229Z | lvl=ERROR | corr=ebf236d8-e24d-4dbd-9cfc-20fd509c4213 | trans=ebf236d8-e24d-4dbd-9cfc-20fd509c4213 | op=IOTAUL.AMQP.Binding | from=n/a | srv=n/a | subsrv=n/a | msg=connect ECONNREFUSED 127.0.0.1:5672 | comp=IoTAgent\n","stream":"stdout","time":"2023-01-04T14:15:51.234099317Z"}

IoT devices commands are misplaced

Hi!
Following the tutorial, I wanted to update or delete provisioned devices, but this part in the readme repeat the same commands for services (instead of devices):
https://github.com/Fiware/tutorials.IoT-Agent/tree/master#update-a-provisioned-device

It'd be great to see the correct commands here.

As for context, I need this for the MQTT part, where I need to update the lamp001 device, because the loaded data doesn't have the commands registered for this device.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.