RWTH-EBC / FiLiP

FIWARE Library for Python (FiLiP) to work with FIWARE API
BSD 3-Clause "New" or "Revised" License
23 stars 13 forks source link

Expressionlanguage in device should be optional #312

Closed djs0109 closed 1 month ago

djs0109 commented 1 month ago

Describe the bug Expressionlanguage is not set as optional in the datamodel of DeviceSettings, which will cause unexpected validation error

To Reproduce

from filip.models.ngsi_v2.iot import Device
test_device = Device.model_validate(  {
    "apikey": "your_apikey",
    "protocol": "IoTA-JSON",
    "transport": "MQTT",
    "expressionLanguage": None,
    "device_id": "device:001",
    "entity_name": "urn:ngsi-ld:WeatherStation:001",
    "entity_type": "WeatherStation",
    "attributes": [
      {
        "name": "sim_time",
        "type": "Number",
        "object_id": "t_sim"
      },
      {
        "name": "temperature",
        "type": "Number",
        "object_id": "t_amb"
      }
    ],
    "ngsiVersion": "v2"
  })

Suggestion

Use expressionLanguage: Optional[ExpressionLanguage] = Field(..., and add a test to prevent this happen again.

djs0109 commented 1 month ago

Hi @RCX112, could you have a look at this issue?

RCX112 commented 1 month ago

@djs0109 I can do that. I should set the expressionLanguage to jexl when it is set to None, otherwise it will be set to legacy in older versions of the IoT Agent

djs0109 commented 1 month ago

@RCX112 Thanks! That sounds good 👍

github-actions[bot] commented 1 month ago

Branch 312-Expressionlanguage-in-device-should-be-optional created!