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

Parameter "cbHost" of ServiceGroup class not working (should be called "cbroker") #204

Closed
RCX112 opened this issue Oct 12, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@RCX112
Copy link
Collaborator

RCX112 commented Oct 12, 2023

Describe the bug
I tried to create different devices and a single service group and wanted to change different attributes by publishing MQTT messages to the IoT Agent. The provisioning worked for me with no errors, but when I tried to change attribute values of my devices via MQTT nothing happened. When I changed the name of the attribute "cbHost" of the class "ServiceGroup" to "cbroker" everything worked for me.

@RCX112 RCX112 added the bug Something isn't working label Oct 12, 2023
@djs0109
Copy link
Contributor

djs0109 commented Oct 12, 2023

Thanks for your reporting! In order to reproduce your problem, could you share:

  1. Your code regarding provisioning devices;
  2. Version of IoTagent and Orion Context Broker?

@RCX112
Copy link
Collaborator Author

RCX112 commented Oct 13, 2023

Sure! Regarding to the second point I checked the service health of my IoT Agent and it has the libVersion 3.4.0 and version 2.4.0. I also checked the Orion Context Broker, which has version 3.10.1.

Now about the first point: I first created my local environment using the Docker images from this repo: https://github.com/FIWARE/tutorials.IoT-over-MQTT.git . Afterwards I provisioned a service group and simple motion sensor device with the filip library:

from filip.models.ngsi_v2.iot import ServiceGroup, Device, DeviceAttribute
from filip.clients.ngsi_v2 import IoTAClient
from filip.models.base import FiwareHeader

fiware_header = FiwareHeader(service="openiot", service_path="/")

iota_client = IoTAClient(url="http://localhost:4041", fiware_header=fiware_header)

service_group = ServiceGroup(service="openiot",
                             subservice="/", apikey="4jggokgpepnvsb2uv4s40d59ov",
                             cbHost="http://localhost:1026", entity_type="Thing",
                             resource="")

motion_sensor_device = Device(service="openiot", service_path="/", device_id="motion001",
                              entity_name="urn:ngsi-ld:Motion:001", entity_type="Motion",
                              protocol="PDI-IoTA-UltraLight", transport="MQTT", timezone="Europe/Berlin",
                              attributes=[DeviceAttribute(object_id="c", name="count", type="Integer")])

iota_client.post_group(service_group, update=True)
iota_client.post_device(device=motion_sensor_device)

Here I used the parameter cbHost for my orion context broker. When I then publish an MQTT message like 'c|1' to change the count attribute of the device to the topic '/ul/4jggokgpepnvsb2uv4s40d59ov/motion001/attrs' nothing happens. But when I change the parameter "cbHost" to "cbroker" everything worked for me and the device attribute gets updated in the context broker.

@djs0109
Copy link
Contributor

djs0109 commented Oct 16, 2023

I think cbHost is the right parameter to used, see here. However, you should not specify it on the service group level, unless you want to override the cbHost on the container level.

I can reproduce your error, but I think you make some little mistakes while provisioning the service group, and device
I change your code a little bit, and it must also work for you.

service_group = ServiceGroup(apikey="4jggokgpepnvsb2uv4s40d59ov",
                             entity_type="Thing",
                             resource="/iot/ul")


motion_sensor_device = Device(device_id="motion002",
                              entity_name="urn:ngsi-ld:Motion:002",
                              entity_type="Motion",
                              protocol="PDI-IoTA-UltraLight",
                              transport="MQTT",
                              attributes=[DeviceAttribute(object_id="c", name="count", type="Integer")])

@djs0109 djs0109 self-assigned this Oct 16, 2023
@github-actions
Copy link

@RCX112
Copy link
Collaborator Author

RCX112 commented Oct 16, 2023

This worked for me thanks 👍 It also works with resource="" for me :)

@djs0109 djs0109 closed this as completed Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants