flavio-fernandes / mqtt2kasa

Python-based project that provides wrapper to python-kasa for MQTT access
MIT License
30 stars 14 forks source link

Doesn't work with aiomqtt 2.0.0 #13

Open normanr opened 9 months ago

normanr commented 9 months ago

Quick fix is to update requirement.txt to have aiomqtt==1.2.1

Longer fix is to follow https://sbtinstruments.github.io/aiomqtt/migration-guide-v2.html

flavio-fernandes commented 9 months ago

Thank you @normanr ! I merged in the temporary fix. Interestingly, I noticed that pip install on a python 3.7 is not picking up aiomqtt 2.0.0, which is probably why I never saw this issue.

For convenience, I started a vm using Vagrant: vagrant up

$ vagrant ssh
(env) vagrant@mqtt2kasaVM:~$ pip list
Package            Version
------------------ -------
aiomqtt            1.1.0
anyio              3.7.1
asyncclick         8.1.7.1
asyncio-throttle   1.0.2
exceptiongroup     1.2.0
idna               3.6
importlib-metadata 6.7.0
paho-mqtt          1.6.1
pip                23.3.2
pydantic           1.10.14
python-kasa        0.5.1
PyYAML             6.0.1
setuptools         47.1.0
sniffio            1.3.0
typing_extensions  4.7.1
zipp               3.15.0
(env) vagrant@mqtt2kasaVM:~$ python --version
Python 3.7.17
(env) vagrant@mqtt2kasaVM:~$ pip install aiomqtt==1.2.1
ERROR: Ignored the following yanked versions: 0.17.0
ERROR: Ignored the following versions that require a different python version: 1.2.0 Requires-Python >=3.8,<4.0; 1.2.1 Requires-Python >=3.8,<4.0; 2.0.0 Requires-Python >=3.8,<4.0
ERROR: Could not find a version that satisfies the requirement aiomqtt==1.2.1 (from versions: 0.1.0, 0.1.1, 0.1.2, 0.1.3, 1.0.0, 1.1.0)
ERROR: No matching distribution found for aiomqtt==1.2.1
(env) vagrant@mqtt2kasaVM:~$ pip install aiomqtt==2.0.0
ERROR: Ignored the following yanked versions: 0.17.0
ERROR: Ignored the following versions that require a different python version: 1.2.0 Requires-Python >=3.8,<4.0; 1.2.1 Requires-Python >=3.8,<4.0; 2.0.0 Requires-Python >=3.8,<4.0
ERROR: Could not find a version that satisfies the requirement aiomqtt==2.0.0 (from versions: 0.1.0, 0.1.1, 0.1.2, 0.1.3, 1.0.0, 1.1.0)
ERROR: No matching distribution found for aiomqtt==2.0.0
(env) vagrant@mqtt2kasaVM:~$ cat /etc/*release*
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
normanr commented 9 months ago

Thanks! Using an ordered comparison <= is better than equality ==, but I wonder if the comparable operator ~= (with the earliest compatible major.minor version) should be used instead. That way it'll pick up new micro or minor releases, but not the major release.

ref: https://packaging.python.org/en/latest/specifications/version-specifiers/#id4

normanr commented 9 months ago

fwiw, Python 3.7 support was dropped in https://github.com/sbtinstruments/aiomqtt/pull/246 which is probably why it didn't detect it.