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

272 mqtt v2 does not work #273

Closed FWuellhorst closed 2 months ago

FWuellhorst commented 4 months ago

Closes #272 Closes #270

I also removed a redundant warning in the subscription handling, which leads to this messages:

18-Apr-2024 12:32:58 INFO: pong/NotifiedAttributesContextBroker: Posting subscription to topic '/agentlib/agentlib/myEmulatorExample/ContextBrokerSubscriptions/pong_NotifiedAttributesContextBroker' with sub'={"id":null,"description":"pong_NotifiedAttributesContextBroker","status":"active","subject":{"entities":[{"id":"ping_entity","idPattern":null,"type":"sensor","typePattern":null}],"condition":{"attrs":["ping_attribute"],"expression":null}},"notification":{"timesSent":null,"http":null,"httpCustom":null,"mqtt":{"url":"mqtt://134.130.56.157:1883","topic":"/agentlib/agentlib/myEmulatorExample/ContextBrokerSubscriptions/pong_NotifiedAttributesContextBroker/ping_entity","qos":0,"user":null,"passwd":null},"mqttCustom":null,"attrs":null,"exceptAttrs":null,"attrsFormat":"normalized","metadata":null,"onlyChangedAttrs":false},"expires":null,"throttling":null}'
d:\01_projekte\02_dzwi\filip\filip\clients\ngsi_v2\cb.py:2031: UserWarning: Different field found:{expression: (None, None)}
  warnings.warn(
d:\01_projekte\02_dzwi\filip\filip\clients\ngsi_v2\cb.py:2031: UserWarning: Different field found:{timesSent: (None, 4)}
  warnings.warn(
d:\01_projekte\02_dzwi\filip\filip\clients\ngsi_v2\cb.py:2031: UserWarning: Different field found:{http: (None, None)}
  warnings.warn(
d:\01_projekte\02_dzwi\filip\filip\clients\ngsi_v2\cb.py:2031: UserWarning: Different field found:{httpCustom: (None, None)}
  warnings.warn(
d:\01_projekte\02_dzwi\filip\filip\clients\ngsi_v2\cb.py:2031: UserWarning: Different field found:{qos: (0, 0)}
  warnings.warn(
d:\01_projekte\02_dzwi\filip\filip\clients\ngsi_v2\cb.py:2031: UserWarning: Different field found:{user: (None, None)}
  warnings.warn(
d:\01_projekte\02_dzwi\filip\filip\clients\ngsi_v2\cb.py:2031: UserWarning: Different field found:{passwd: (None, None)}
  warnings.warn(
d:\01_projekte\02_dzwi\filip\filip\clients\ngsi_v2\cb.py:2031: UserWarning: Different field found:{mqttCustom: (None, None)}
  warnings.warn(
d:\01_projekte\02_dzwi\filip\filip\clients\ngsi_v2\cb.py:2031: UserWarning: Different field found:{attrs: (None, [])}
  warnings.warn(
d:\01_projekte\02_dzwi\filip\filip\clients\ngsi_v2\cb.py:2031: UserWarning: Different field found:{exceptAttrs: (None, None)}
  warnings.warn(
d:\01_projekte\02_dzwi\filip\filip\clients\ngsi_v2\cb.py:2031: UserWarning: Different field found:{metadata: (None, None)}
  warnings.warn(
d:\01_projekte\02_dzwi\filip\filip\clients\ngsi_v2\cb.py:2031: UserWarning: Different field found:{onlyChangedAttrs: (False, False)}
  warnings.warn(

However, the lines below already if both are None and handle them correctly:

            if v != ex_value:
                self.logger.debug(f"Not equal fields for key {k}: ({v}, {ex_value})")
                if not _value_is_not_none(v) and not _value_is_not_none(ex_value) or k == "timesSent":
                    continue
                return False
tstorek commented 4 months ago

@FWuellhorst Thanks, for the hotfix. is it correct to mix the API versions? Wouldn't it be better to completely work wirh API-Version V2? Maybe we should split this one in the hotfix and the refactoring issue.

djs0109 commented 4 months ago

The hotfix is moved to #276

djs0109 commented 4 months ago

I will also suggest that we should completely upgrade to VERSION2 in this PR. @FWuellhorst can you manage to implement that? Otherwise we can still find someone to take over

FWuellhorst commented 4 months ago

It works for me, I don't have the capacity to update each client usage. We can also merge this an open a new issue.

tstorek commented 2 months ago

@djs0109 any news on this?

djs0109 commented 2 months ago

@tstorek we are still reviewing it. If nothing important is missing, it would be merged till next week.