Skip to content

MQTT publisher uses deprecated paho-mqtt v1 callback API #15

Closed

Description

@ritwiktiwari

Reviewing for JOSS (openjournals/joss-reviews#11038) on v0.9.2.

mqtt_publisher.py uses the paho-mqtt v1 callback API. pyproject.toml declares paho-mqtt>=2.0.0, which means every user gets the v2 library, but the code talks to it using the old interface. This currently produces a DeprecationWarning on every instantiation and will break when the v1 API is removed.

Where in code:

  • mqtt_publisher.py#L118mqtt.Client(client_id=client_id) without CallbackAPIVersion
  • mqtt_publisher.py#L133 _on_connect(self, client, userdata, flags, rc) uses the 4-parameter v1 signature (v2 uses 5 parameters: client, userdata, flags, reason_code, properties)

Steps to reproduce:

import warnings
warnings.simplefilter("always")

from wattameter.mqtt_publisher import MQTTPublisher
pub = MQTTPublisher(broker_host="localhost")
Image

Suggested fix:

# Before (v1)
self.client = mqtt.Client(client_id=client_id)

# After (v2)
self.client = mqtt.Client(
    callback_api_version=mqtt.CallbackAPIVersion.VERSION2,
    client_id=client_id,
)

Update _on_connect to the 5-parameter signature:

# Before
def _on_connect(self, client, userdata, flags, rc):

# After
def _on_connect(self, client, userdata, flags, reason_code, properties):

Same for _on_disconnect and _on_publish.

Activity

  1. added 2 commits that reference this issue on Sep 15, 2026
  2. weslleyspereira commented on Sep 15, 2026

    @weslleyspereira
    Collaborator

    Should be resolved with #32. Please let us know if not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions