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

288 filip support right now only paylaod in mqtt custom / http custom but orion already supports json and ngsi as further options #296

Closed SystemsPurge closed 1 month ago

SystemsPurge commented 2 months ago

The following warning pops up "UserWarning: Field name "json" shadows an attribute in parent "Mqtt"" ( due to the json fields in MqttCustom and HttpCustom ). Since the Http/Mqtt models do not have an explicit json field, i take it this is coming from some field/property in the base model. Tried to circumvent the warning by the use of aliases which obviously did not work.

Not sure what model to specify for the json payload type, i just put a Dict[str, any] for now ( despite number/string being valid json , the orion manual specifies that it needs to be a JSON object and not an object of primitive type )

Any input on these two points is welcome.

djs0109 commented 2 months ago

closes #288

djs0109 commented 2 months ago

I think it would be great if we can test the functionality of these fields too. @RCX112 Could you please implement a test that uses json, ngsi, payload for mqttCustom? An example can be found here https://github.com/RWTH-EBC/FiLiP/blob/7919664cad1d7ff3800724f819a7c9f43bd28a80/tests/clients/test_ngsi_v2_cb.py#L832

RCX112 commented 1 month ago

The following warning pops up "UserWarning: Field name "json" shadows an attribute in parent "Mqtt"" ( due to the json fields in MqttCustom and HttpCustom ). Since the Http/Mqtt models do not have an explicit json field, i take it this is coming from some field/property in the base model. Tried to circumvent the warning by the use of aliases which obviously did not work.

Not sure what model to specify for the json payload type, i just put a Dict[str, any] for now ( despite number/string being valid json , the orion manual specifies that it needs to be a JSON object and not an object of primitive type )

Any input on these two points is welcome.

@SystemsPurge When I implemented the HttpCustom model I also had the same warnings. I simply supressed them with the warnings library, because the json() method of pydantic is already outdated anyway:

import warnings

# The pydantic models still have a .json() function, but this method is deprecated.
warnings.filterwarnings("ignore", category=UserWarning,
                        message='Field name "json" shadows an attribute in parent "Http"')
warnings.filterwarnings("ignore", category=UserWarning,
                        message='Field name "json" shadows an attribute in parent "Mqtt"')
RCX112 commented 1 month ago

@djs0109 Which version of Orion do we currently use for the tests, because the custom notifications don't work for version 3.7 for example?

djs0109 commented 1 month ago

Hi @RCX112 , it should be Orion >= 3.8, I have tested with 3.8.1