I am developing an IoT application using FIWARE IoT Agent-JSON and Mosquitto. I create test devices, assign sensors to these devices, and publish data for these sensors via Mosquitto. I can correctly see the attributes of the sensors connected to the devices in the IoT Agent's iotagentul.devices and iotagentul.EysDevices tables in MongoDB. However, in the orion-acd table in the Orion Context Broker, I see all the sensor attributes published via Mosquitto, while I only want to see the attributes of the sensors I have connected to the devices.
In Orion Context Broker, I only want to see the attributes of the sensors connected to the devices. Sensor attributes published via Mosquitto but not connected to the devices also appear in this table. I'm curious about the reason and solution to this situation.
Configuration Details: Docker-compose.yml file:
version: "3.8"
services:
# Orion is the context broker
orion:
image: fiware/orion:3.7.0
hostname: orion
container_name: fiware-orion-pms
networks:
- default
expose:
- "${ORION_PORT}"
ports:
- "${ORION_PORT}:${ORION_PORT}" # localhost:1026
command: -dbhost $IP_ADDRESS:27030 -dbuser $DB_USER -dbpwd $DB_PWD -dbAuthDb admin -db orion -logLevel DEBUG
healthcheck:
test: curl --fail -s http://orion:${ORION_PORT}/version || exit 1
interval: 5s
restart: always
labels:
maintainer: ino
description: fiware-orion
project: pms
version: v1.0.0
type: fiware
deploy:
resources:
limits:
cpus: '0.5' # maksimum 0.5 CPU çekirdeği
memory: 512M # maksimum 512 megabayt bellek
logging:
driver: "json-file" # Here, we're using the json-file driver for logging
options:
max-size: "1g" # Set the maximum size for a log file (e.g., 1 GB)
max-file: "5" # Set the maximum number of log files to keep
iot-agent:
image: fiware/iotagent-json
hostname: iot-agent
container_name: fiware-iot-agent-pms
networks:
- default
expose:
- "${IOTA_NORTH_PORT}"
ports:
- "${IOTA_NORTH_PORT}:${IOTA_NORTH_PORT}" # localhost:4041
environment:
- IOTA_CB_HOST=${IP_ADDRESS} # name of the context broker to update context
- IOTA_CB_PORT=1026 # port the context broker listens on to update context
- IOTA_NORTH_PORT=4041
- IOTA_REGISTRY_TYPE=mongodb #Whether to hold IoT device info in memory or in a database
- IOTA_LOG_LEVEL=DEBUG # The log level of the IoT Agent
- IOTA_TIMESTAMP=true # Supply timestamp information with each measurement
- IOTA_CB_NGSI_VERSION=v2 # use NGSIv2 when sending updates for active attributes
- IOTA_AUTOCAST=true # Ensure Ultralight number values are read as numbers not strings
- IOTA_MONGO_USER=$DB_USER
- IOTA_MONGO_PASSWORD=$DB_PWD
- IOTA_MONGO_AUTH_SOURCE=admin
- IOTA_MONGO_HOST=$IP_ADDRESS # The host name of MongoDB
- IOTA_MONGO_PORT=27030 # The port mongoDB is listening on
- IOTA_MONGO_DB=iotagentul # The name of the database used in mongoDB
- IOTA_MQTT_HOST=$MQTT_HOST # The host name of the MQTT Broker
- IOTA_MQTT_PORT=1883 # The port the MQTT Broker is listening on to receive topics
- IOTA_DEFAULT_RESOURCE= # Default is blank. I'm using MQTT so I don't need a resource
- IOTA_PROVIDER_URL=http://iot-agent:${IOTA_NORTH_PORT}
- IOTA_DEFAULT_TRANSPORT=MQTT
healthcheck:
interval: 5s
restart: always
labels:
maintainer: ino
description: fiware-orion-agent-json
project: pms
version: v1.0.0
type: fiware
deploy:
resources:
limits:
cpus: '0.5' # maksimum 0.5 CPU çekirdeği
memory: 512M # maksimum 512 megabayt bellek
logging:
driver: "json-file" # Here, we're using the json-file driver for logging
options:
max-size: "1g" # Set the maximum size for a log file (e.g., 1 GB)
max-file: "5" # Set the maximum number of log files to keep
networks:
default:
labels:
org.fiware: 'fiware-networks-pms'
ipam:
config:
- subnet: 172.50.1.0/24
Sample record in iotagentul.devices table:
{
"_id": {
"$oid": "665ee84cfc6591f112df952a"
},
"lazy": [],
"active": [
{
"name": "Current_L1",
"type": "Double",
"object_id": "Current_L1"
}
],
"commands": [],
"staticAttributes": [
{
"name": "refStore",
"type": "Relationship",
"value": "urn:ngsi-ld:pa_DEVICE1:001"
}
],
"creationDate": {
"$date": "2024-06-04T10:11:24.071Z"
},
"id": "PA_DEVICE1",
"type": "pa",
"name": "PA_DEVICE1",
"service": "acd",
"subservice": "/pa/DEVICE1",
"internalId": null,
"transport": "HTTP",
"polling": true,
"__v": 1,
"apikey": "acd_PA_DEVICE1",
"subscriptions": []
}
Sample record in orion-acd table:
{
"_id": {
"id": "PA_DEVICE1",
"type": "pa",
"servicePath": "/pa/DEVICE1"
},
"attrNames": [
"refStore",
"Current_L1",
"Voltage_UL1_N",
"Voltage_UL2_N",
"Voltage_UL3_N",
"Current_L2",
"Current_L3",
"Total_Consumed_Energy",
"Total_Power_Factor",
"Total_Reactive_Power",
"Total_Apparent_Power",
"Total_Active_Power",
"TimeInstant"
],
"attrs": {
...
},
"creDate": 1717495904.300415,
"modDate": 1717583504.3732698,
"lastCorrelator": "ce017f3a-2326-11ef-b4d0-0242ac320102"
}
Question 1: What should I do to prevent sensor attributes that come via Mosquitto and are not connected to devices from appearing in the Orion table?
Quesiton2 :What changes do I need to make to the IoT Agent or Orion configuration to resolve this issue?
I would welcome any help. Thanks!
Not sure if I'm understanding it correctly (btw you should report via IotAgent and NGSIv2 API no mongoDumps), but if you only want to propagate provisioned active and static attrs (Current_L1
and refStore
) you may use the explicitAttrs
option at group or device configuration.
With explicitAttrs = true
just provisioned attrs will be propagated. By default every measure gets propagated to the NGSI interface (you may change this default behavior via general config).
In order to create or modify a Group or a device use the provison API (where explicitAttrs is a firstlevel key):
https://github.com/telefonicaid/iotagent-node-lib/blob/master/doc/api.md#config-group-api