Code Monkey home page Code Monkey logo

Comments (6)

dmoranj avatar dmoranj commented on June 1, 2024

In last versions of the IoTA Library, a small change was introduced in the provisioning API, that may be wrongly specified in some examples. In the specification of attributes:

"lazy":[
                  { "id": "l", "name": "luminosity", "type": "percentage" }
            ],

the id field should be named object_id. We have several tasks pending for updating documentation and examples. Next week I'll try to put the documentation up to date. Sorry for the inconvenience.

from iotagent-json.

drasko avatar drasko commented on June 1, 2024

@dmoranj yes, indeed I can notice here: https://github.com/telefonicaid/iotagent-mqtt/blob/master/test/deviceProvisioning/provisionDevice2.json#L19

However, I see that "id" field has disappeared from "attributes" and "commands"... Should we also use "object_id" over there?

What is exact role of "object_id" anyway?

I think this part of doc must be updated: https://github.com/telefonicaid/iotagent-node-lib#-device-provisioning-api

Anyway, this command:

(curl localhost:4041/iot/devices -s -S --header 'Content-Type: application/json' \
    --header 'Accept: application/json' --header 'Fiware-Service: mainflux' --header 'Fiware-ServicePath: /mqtt' -d @- | python -mjson.tool) <<EOF
{
    "devices": [ 
        { 
            "device_id": "DevID1", 
            "entity_name": "TheDevice1", 
            "entity_type": "DeviceType", 
            "attributes": [ 
                  { "object_id": "t", "name": "temperature", "type": "float" },
                  { "object_id": "h", "name": "humidity", "type": "float" }
            ],
            "lazy":[
                  { "object_id": "l", "name": "luminosity", "type": "percentage" }
            ],
            "commands": [
                  { "object_id": "t", "name": "turn", "type": "string" }
            ],
            "static_attributes": [
                  { "name": "serialID", "type": "02598347" }
            ]
        }
    ]
} 
EOF

passes OK.

Entry in the Oprion's database is following:

> db.entities.find()
{ "_id" : { "id" : "TheDevice1", "type" : "DeviceType", "servicePath" : "/mqtt" }, "attrNames" : [ "temperature", "humidity", "serialID", "turn_status", "turn_result" ], "attrs" : { "temperature" : { "type" : "float", "creDate" : 1454795350, "modDate" : 1454795350, "value" : " " }, "humidity" : { "type" : "float", "creDate" : 1454795350, "modDate" : 1454795350, "value" : " " }, "serialID" : { "type" : "02598347", "creDate" : 1454795350, "modDate" : 1454795804 }, "turn_status" : { "type" : "commandStatus", "creDate" : 1454795350, "modDate" : 1454795350, "value" : "UNKNOWN" }, "turn_result" : { "type" : "commandResult", "creDate" : 1454795350, "modDate" : 1454795350, "value" : " " } }, "creDate" : 1454795350, "modDate" : 1454795804 }

And Orion's log is following:

orion_1 | INFO@21:56:44  logMsg.h[1802]: Starting transaction from 172.17.42.1:56184/NGSI9/registerContext
orion_1 | INFO@21:56:44  connectionOperations.cpp[79]: Database Operation Successful (query: { $or: [ { entities: { $in: [ { id: "TheDevice1", type: "DeviceType", isPattern: "false" } ] }, $or: [ { attrs: { $in: [ "luminosity", "turn" ] } }, { attrs: { $size: 0 } } ], expiration: { $gt: 1454795804 } }, { entities.isPattern: "true", expiration: { $gt: 1454795804 }, $where: function(){enId = [ "TheDevice1" ];enType = [ "DeviceType" ];for (var ... } ] })
orion_1 | INFO@21:56:44  connectionOperations.cpp[400]: Database Operation Successful (update: <{ _id: ObjectId('56b66c1c20bef1003a5da142') }, { _id: ObjectId('56b66c1c20bef1003a5da142'), expiration: 1457387804, servicePath: "/mqtt", format: "JSON", contextRegistration: [ { entities: [ { id: "TheDevice1", type: "DeviceType" } ], attrs: [ { name: "luminosity", type: "percentage", isDomain: "false" }, { name: "turn", type: "string", isDomain: "false" } ], providingApplication: "http://localhost:4041" } ] }>)
orion_1 | INFO@21:56:44  logMsg.h[1886]: Transaction ended
orion_1 | INFO@21:56:44  logMsg.h[1802]: Starting transaction from 172.17.42.1:56186/v1/updateContext
orion_1 | INFO@21:56:44  connectionOperations.cpp[79]: Database Operation Successful (query: { _id.id: "TheDevice1", _id.type: "DeviceType", _id.servicePath: /^\/mqtt$/ })
orion_1 | ERROR@21:56:44  safeMongo.cpp[198]: Runtime Error (field 'value' is missing in BSONObj <{ type: "02598347", creDate: 1454795350, modDate: 1454795771 }>)
orion_1 | ERROR@21:56:44  safeMongo.cpp[198]: Runtime Error (field 'value' is missing in BSONObj <{ type: "02598347", creDate: 1454795350, modDate: 1454795771 }>)
orion_1 | ERROR@21:56:44  MongoCommonUpdate.cpp[555]: Runtime Error (unknown attribute value type in DB: 0)
orion_1 | INFO@21:56:44  connectionOperations.cpp[400]: Database Operation Successful (update: <{ _id.id: "TheDevice1", _id.type: "DeviceType", _id.servicePath: /\/mqtt/ }, { $set: { attrs.serialID: { type: "02598347", creDate: 1454795350, modDate: 1454795804 }, modDate: 1454795804 }, $unset: { location: 1 } }>)
orion_1 | INFO@21:56:44  logMsg.h[1886]: Transaction ended
orion_1 | INFO@21:56:49  connectionOperations.cpp[625]: Database Operation Successful (command: { listDatabases: 1 })
orion_1 | INFO@21:56:49  connectionOperations.cpp[79]: Database Operation Successful (query: { conditions.type: "ONCHANGE" })
orion_1 | INFO@21:56:49  connectionOperations.cpp[79]: Database Operation Successful (query: { conditions.type: "ONCHANGE" })

Looks like it dows not like that we are not passing the value...

from iotagent-json.

dmoranj avatar dmoranj commented on June 1, 2024

The documentation has to be updated in the IOTA Lib, indeed. BTW, lazy attributes and commands haven't been implemented yet for the MQTT-JSON IoTA. I'll try to create the Step-by-step guide today, to solve your doubts one and for all.

from iotagent-json.

drasko avatar drasko commented on June 1, 2024

@dmoranj no need - it has been done already ;). Take a look at #84, I have already posted you this link: https://github.com/Mainflux/mainflux-fiware/wiki/IoT-Agent-MQTT

I made an extensive step-by-step guide, all you need is to copy-paste it to the IOTA-MQTT page.

from iotagent-json.

dmoranj avatar dmoranj commented on June 1, 2024

Thanks for the effort :)

I was thinking of something more structured like the guide we created for the LWM2M Agent. I'm working already on that.

from iotagent-json.

dmoranj avatar dmoranj commented on June 1, 2024

Closing issue, as it seems to contain already answered questions and some issues regarding the documentation (fixed in #84 or in another PR in the IOTAgent Library documentation).

from iotagent-json.

Related Issues (20)

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.