diff --git a/usbrelay-paho-mqttv2.patch b/usbrelay-paho-mqttv2.patch new file mode 100644 index 0000000..c9dd774 --- /dev/null +++ b/usbrelay-paho-mqttv2.patch @@ -0,0 +1,28 @@ +From 58fed08a2a1b10122360845c780c9fa17cf9d6b3 Mon Sep 17 00:00:00 2001 +From: Michal Sojka +Date: Tue, 30 Apr 2024 14:03:40 +0200 +Subject: [PATCH] usbrelayd: Add support for paho-mqtt >= 2.0.0 + +See https://eclipse.dev/paho/files/paho.mqtt.python/html/migrations.html#change-between-version-1-x-and-2-0 +--- + usbrelayd | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/usbrelayd b/usbrelayd +index 60c13dc..10bfe1e 100644 +--- a/usbrelayd ++++ b/usbrelayd +@@ -95,7 +95,12 @@ else: + # connect to the mqtt broker + + +-client = mqtt.Client(clientName) ++if "CallbackAPIVersion" in dir(mqtt): ++ # paho-mqtt >= 2.0.0 ++ client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1, clientName) ++else: ++ # paho-mqtt < 2.0.0 ++ client = mqtt.Client(clientName) + client.connect(mqttBroker) + publish_states(client) + client.on_message=on_message diff --git a/usbrelay.spec b/usbrelay.spec index 4c9046d..8094deb 100644 --- a/usbrelay.spec +++ b/usbrelay.spec @@ -5,16 +5,13 @@ Summary: A library and command line tool to control USB-connected relays License: GPL-2.0-or-later URL: https://github.com/darrylb123/%{name} Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz +# https://github.com/darrylb123/usbrelay/pull/112 +Patch1: usbrelay-paho-mqttv2.patch BuildRequires: gcc BuildRequires: hidapi-devel BuildRequires: make -BuildRequires: python3 BuildRequires: python3-devel -BuildRequires: python3-pip -BuildRequires: python3-toml -BuildRequires: python3-wheel -BuildRequires: python3-tox-current-env BuildRequires: systemd-rpm-macros Requires: systemd-udev @@ -141,7 +138,6 @@ groupadd --force --system usbrelay %{python3_sitearch}/%{name}_py*.dist-info %{python3_sitearch}/%{name} - %files mqtt %{_sbindir}/usbrelayd %{_unitdir}/usbrelayd.service