chore: adapt changes to iota according to new version#485
Open
chore: adapt changes to iota according to new version#485
Conversation
sbanoeon
commented
Mar 11, 2026
| print("Wrong port error message:", str(cm.exception)) | ||
| self.assertIsInstance(cm.exception.__cause__, requests.RequestException) | ||
|
|
||
| @pytest.mark.skip(reason="Not ready yet") |
Contributor
Author
There was a problem hiding this comment.
@djs0109 These are the tests which are still failing.
sbanoeon
commented
Mar 11, 2026
| entity.delete_attributes(["test3"]) | ||
| self.assertEqual(entity.get_attribute_names(), set()) | ||
|
|
||
| @pytest.mark.skip(reason="Not ready yet") |
Contributor
Author
There was a problem hiding this comment.
@djs0109 These are the tests which are still failing.
sbanoeon
commented
Mar 11, 2026
|
|
||
| self.client.delete_entity(entity_id="string_test", entity_type="test_type1") | ||
|
|
||
| @pytest.mark.skip(reason="Not ready yet") |
Contributor
Author
There was a problem hiding this comment.
@djs0109 These are the tests which are still failing.
Collaborator
|
Regarding commands I found the latest documentation
|
…' into 489-Support-Orion-4-X # Conflicts: # docker/docker-compose.yml
Collaborator
|
Here is a script to test the mqtt command of iotagent import requests
import time
import paho.mqtt.client as mqtt
import paho.mqtt.publish as publish
from paho.mqtt.enums import CallbackAPIVersion
# ==========================================
# CONFIGURATION & SETUP
# ==========================================
HOST = "..." # TODO
IOTA_URL = f"http://{HOST}:4041"
ORION_URL = f"http://{HOST}:1026"
MQTT_PORT = 1883
API_KEY = "testapikey"
# Initialize a session to avoid repeating headers
session = requests.Session()
session.headers.update({
'fiware-service': 'filip_jdu',
'fiware-servicepath': '/'
})
def print_response(step_name, response):
"""Helper function to print responses clearly."""
print(f"\n--- {step_name} ---")
print(f"Status Code: {response.status_code}")
print(response.text)
def on_connect(client, userdata, flags, rc):
print(f"\n[MQTT] Connected to broker with result code {rc}")
# Subscribe to all topics using the wildcard '#'
client.subscribe("#")
def on_message(client, userdata, msg):
print(f"\n[MQTT MESSAGE RECEIVED] Topic: {msg.topic} | Payload: {msg.payload.decode()}")
# Setup the MQTT client and start the listening loop in the background
mqtt_client = mqtt.Client(callback_api_version=CallbackAPIVersion.VERSION1)
mqtt_client.on_connect = on_connect
mqtt_client.on_message = on_message
mqtt_client.connect(HOST, MQTT_PORT, 60)
mqtt_client.loop_start()
# Give the MQTT client a brief moment to connect before firing API requests
time.sleep(1)
# ==========================================
# API EXECUTION FLOW
# ==========================================
# 1. Get IoT Agent Version
res = session.get(f"{IOTA_URL}/version")
print_response("IoT Agent Version", res)
# 2. Create Group
group_payload = {
"groups": [
{
"resource": "/iot/json",
"apikey": API_KEY,
"entity_type": "Actuator",
"transport": "MQTT"
}
]
}
res = session.post(f"{IOTA_URL}/iot/groups", json=group_payload)
print_response("Create Group", res)
# 3. Get Groups
res = session.get(f"{IOTA_URL}/iot/groups")
print_response("Get Groups", res)
# 4. Create Sensor Device
sensor_payload = {
"devices": [
{
"device_id": "sensor:001",
"entity_name": "sensor:001",
"entity_type": "sensor",
"apikey": API_KEY,
"attributes": [{"name": "temperature", "type": "Number"}],
"ngsiVersion": "v2"
}
]
}
res = session.post(f"{IOTA_URL}/iot/devices", json=sensor_payload)
print_response("Create Sensor Device", res)
# 5. Send MQTT msg to simulate sensor reading
print("\n--- Sending MQTT Sensor Reading ---")
sensor_topic = f"/json/{API_KEY}/sensor:001/attrs"
sensor_msg = '{"temperature": 20}'
publish.single(sensor_topic, payload=sensor_msg, hostname=HOST, port=MQTT_PORT)
time.sleep(1) # Pause slightly to allow Orion to process the update
# 6. Check Entity (sensor:001)
res = session.get(f"{ORION_URL}/v2/entities/sensor:001")
print_response("Check Sensor Entity in Orion", res)
# 7. Create Actuator Device
actuator_payload = {
"devices": [
{
"device_id": "actuator:004",
"entity_name": "actuator:004",
"entity_type": "Actuator",
"cmdMode": "notification",
"apikey": API_KEY,
"commands": [{"name": "on", "type": "command"}],
"ngsiVersion": "v2"
}
]
}
res = session.post(f"{IOTA_URL}/iot/devices", json=actuator_payload)
print_response("Create Actuator Device", res)
# 8. Check Subscription Created
res = session.get(f"{ORION_URL}/v2/subscriptions/")
print_response("Check Subscriptions", res)
# 9. Update Command (Send command to Actuator)
command_payload = {
"on": {
"type": "command",
"value": 1
}
}
res = session.patch(f"{ORION_URL}/v2/entities/actuator:004/attrs?type=Actuator", json=command_payload)
print_response("Send Command to Actuator", res)
# Keep script running briefly to ensure the background MQTT listener catches the final command
time.sleep(2)
mqtt_client.loop_stop() |
Collaborator
|
@sbanoeon could you please test the behavior as well? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #333