Skip to content

Commit

Permalink
fix: update paho-mqtt dependency version range
Browse files Browse the repository at this point in the history
Expand paho-mqtt version constraint to allow minor version updates up to version 3. This should make libdeye compatible with homeassistant 2025.3
  • Loading branch information
stackia committed Mar 6, 2025
1 parent b65ef11 commit c8980d8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ python_requires = >=3.10
install_requires =
aiohttp>=3.8,<4.0
PyJWT>=2.0,<3.0
paho-mqtt>=1.6,<2
paho-mqtt>=1.6,<3

[options.package_data]
libdeye = py.typed
Expand Down
8 changes: 4 additions & 4 deletions src/libdeye/mqtt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(
self._mqtt.on_connect = self._mqtt_on_connect
self._mqtt.on_message = self._mqtt_on_message
self._mqtt.on_disconnect = self._mqtt_on_disconnect
self._subscribers: dict[str, set[Callable[[mqtt.MQTTMessage], None]]] = {}
self._subscribers: dict[str, set[Callable[[Any], None]]] = {}
self._pending_commands: list[tuple[str, bytes]] = []

@abstractmethod
Expand All @@ -64,8 +64,8 @@ def _mqtt_on_connect(
_mqtt: mqtt.Client,
_userdata: None,
_flags: dict[str, int],
_result_code: int,
_properties: mqtt.Properties | None = None,
_result_code: Any,
_properties: Any,
) -> None:
for topic, callbacks in self._subscribers.items():
if len(callbacks) > 0:
Expand Down Expand Up @@ -110,7 +110,7 @@ def _mqtt_on_message(
def _subscribe_topic(
self,
topic: str,
callback: Callable[[mqtt.MQTTMessage], None],
callback: Callable[[Any], None],
) -> Callable[[], None]:
if topic not in self._subscribers:
self._subscribers[topic] = set()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_mqtt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_mqtt_on_connect(self, base_client: MockBaseDeyeMqttClient) -> None:
# Call _mqtt_on_connect
with patch.object(base_client._mqtt, "subscribe") as mock_subscribe:
with patch.object(base_client._mqtt, "publish") as mock_publish:
base_client._mqtt_on_connect(base_client._mqtt, None, {}, 0)
base_client._mqtt_on_connect(base_client._mqtt, None, {}, 0, {})
mock_subscribe.assert_called_once_with(topic1)
mock_publish.assert_called_once_with(pending_topic, pending_command)
assert len(base_client._pending_commands) == 0
Expand Down Expand Up @@ -278,7 +278,7 @@ async def test_set_mqtt_info(self, classic_client: DeyeClassicMqttClient) -> Non
assert classic_client._mqtt_host == "test.mqtt.host"
assert classic_client._mqtt_ssl_port == 8883
assert classic_client._endpoint == "test_endpoint"
classic_client._mqtt.username_pw_set.assert_called_once_with(
cast(MagicMock, classic_client._mqtt).username_pw_set.assert_called_once_with(
"test_user", "test_password"
)

Expand Down Expand Up @@ -458,7 +458,7 @@ async def test_set_mqtt_info(self, fog_client: DeyeFogMqttClient) -> None:
assert fog_client._mqtt_host == "test.mqtt.host"
assert fog_client._mqtt_ssl_port == 8883
assert fog_client._topic == "fogcloud/app/test_user/sub"
fog_client._mqtt.username_pw_set.assert_called_once_with(
cast(MagicMock, fog_client._mqtt).username_pw_set.assert_called_once_with(
"test_user", "test_password"
)

Expand Down

0 comments on commit c8980d8

Please sign in to comment.