Client-Id transfered to MQTT-Broker
TopGoalVl opened this issue · 13 comments
Will the Client_Id be transferred to the MQTT Broker soon if it is entered in the Config,yml?
Thank you.
You have to restart sml2mqtt
The client ID from config.yml is not sent to the MQTT broker (see log file). A client ID is automatically generated by the broker.
In this case: "auto-CA854A93-5F42-0019-B7F1-612FDDCEF4CF"
Your CmndLine Parameters: (p2, c1, k60, u'xxxxxxxx') without client-Id!
Mosquitto log extract:
2023-02-16T19:57:29: New connection from 192.168.1.47:55577 on port 1883.
2023-02-16T19:57:29: New client connected from 192.168.1.47:55577 as auto-CA854A93-5F42-0019-B7F1-612FDDCEF4CF (p2, c1, k60, u'xxxxxxxxx').
My config section:
MQTT Broker mosquitto or
MQTT Broker IOB Adapter
Section connection MQTT
mqtt:
connection:
client id: smhogw1
host: '192.168.1.47'
port: '1883'
user: 'xxxxxxxxx'
password: '******************'
tls: False
tls insecure: False
I've fixed the issue in the rework branch. Would you be willing to test this branch?
Is there a description of how I have to install the "rework" test environment?
You can install directly from git through
python3 -m pip install git+https://github.com/spacemanspiff2007/sml2mqtt.git@rework
Thanks. I'll report after testing.
=====================================================================================
Test install sml2mqtt.git@rework:
python3 -m pip install git+https://github.com/spacemanspiff2007/sml2mqtt.git@rework
-------------------------------------------------------------------------------------
=====> See the error msg. below.
(venv) pi@smhogw1:/ $ python3 -m pip install git+https://github.com/spacemanspiff2007/sml2mqtt.git@rework
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting git+https://github.com/spacemanspiff2007/sml2mqtt.git@rework
Cloning https://github.com/spacemanspiff2007/sml2mqtt.git (to revision rework) to /tmp/pip-req-build-rewtm4ey
Running command git clone --filter=blob:none --quiet https://github.com/spacemanspiff2007/sml2mqtt.git /tmp/pip-req-build-rewtm4ey
Running command git checkout -b rework --track origin/rework
Zu neuem Branch 'rework' gewechselt
Branch 'rework' folgt nun Remote-Branch 'rework' von 'origin'.
Resolved https://github.com/spacemanspiff2007/sml2mqtt.git to commit 1e259f8f5b4ebe4c97ae94e4878adebd696242ac
Preparing metadata (setup.py) ... done
Requirement already satisfied: asyncio-mqtt==0.16.1 in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from sml2mqtt==1.2.2) (0.16.1)
Requirement already satisfied: pyserial-asyncio==0.6 in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from sml2mqtt==1.2.2) (0.6)
Collecting easyconfig==0.2.8
Downloading https://www.piwheels.org/simple/easyconfig/easyconfig-0.2.8-py3-none-any.whl (17 kB)
Requirement already satisfied: pydantic<2.0,>=1.10 in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from sml2mqtt==1.2.2) (1.10.4)
Requirement already satisfied: smllib==1.2 in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from sml2mqtt==1.2.2) (1.2)
Requirement already satisfied: paho-mqtt>=1.6.0 in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from asyncio-mqtt==0.16.1->sml2mqtt==1.2.2) (1.6.1)
Requirement already satisfied: typing-extensions>=4.4.0 in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from asyncio-mqtt==0.16.1->sml2mqtt==1.2.2) (4.4.0)
Requirement already satisfied: ruamel.yaml<0.18,>=0.17 in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from easyconfig==0.2.8->sml2mqtt==1.2.2) (0.17.21)
Requirement already satisfied: pyserial in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from pyserial-asyncio==0.6->sml2mqtt==1.2.2) (3.5)
Requirement already satisfied: ruamel.yaml.clib>=0.2.6 in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from ruamel.yaml<0.18,>=0.17->easyconfig==0.2.8->sml2mqtt==1.2.2) (0.2.7)
Installing collected packages: easyconfig
Attempting uninstall: easyconfig
Found existing installation: easyconfig 0.2.6
Uninstalling easyconfig-0.2.6:
Successfully uninstalled easyconfig-0.2.6
=====> Is this a problem?
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
sml2mqtt 1.2.2 requires easyconfig==0.2.6, but you have easyconfig 0.2.8 which is incompatible.
Successfully installed easyconfig-0.2.8
=====> Is this a problem?
[notice] A new release of pip available: 22.3.1 -> 23.0.1
[notice] To update, run: pip install --upgrade pip
(venv) pi@smhogw1:/ $
If should run nonetheless. Just try starting it.
I started, no change from version 1.2.2-fix. It looks like sml2mqtt.git@rework is not active.
Hm - could you remove the old installation python3 -m pip pip uninstall sml2mqtt
and only then install the dev branch?
In your sml2mqtt@rework are two files with requirements (requirements.txt / requirements_setup.txt):
requirements.txt
-r requirements_setup.txt
# Testing
pytest >= 7.1, < 8
pre-commit >= 2, < 3
pytest-asyncio >= 0.19, < 0.20
requirements_setup.txt
asyncio-mqtt == 0.16.1
pyserial-asyncio == 0.6
easyconfig == 0.2.8
pydantic >= 1.10, <2.0
smllib == 1.2
Is that correct?
Okay, I will remove the 1.2.2-fix Version.
python3 -m pip uninstall sml2mqtt
The previous uninstall helped. In addition, I removed a Python 3.7 version that might have been a nuisance.
The new installation went without any problems. The client ID is now correctly transmitted to the Mqtt broker (see MQTT log and test result below).
When will the new version be released?
Thank you for the good support.
P.S. One more question.
Which Python library can you recommend for GPIO programming for the Raspberry Pi?
-------------------------------------------------------------------------------------
Test install sml2mqtt.git@rework:
python3 -m pip install git+https://github.com/spacemanspiff2007/sml2mqtt.git@rework
-------------------------------------------------------------------------------------
Uninstall sml2mqtt 1.2.2-fix:
=============================
pi@smhogw1:~ $ source /opt/sml2mqtt/venv/bin/activate
(venv) pi@smhogw1~ $ python3 -m pip uninstall sml2mqtt
Found existing installation: sml2mqtt 1.2.2
Uninstalling sml2mqtt-1.2.2:
Would remove:
/opt/sml2mqtt/venv/bin/sml2mqtt
/opt/sml2mqtt/venv/lib/python3.8/site-packages/sml2mqtt-1.2.2.dist-info/*
/opt/sml2mqtt/venv/lib/python3.8/site-packages/sml2mqtt/*
Proceed (Y/n)? y
Successfully uninstalled sml2mqtt-1.2.2
Package list (sml2mqtt is uninstalled):
=======================================
(venv) pi@smhogw1:~ $ pip3 list
Package Version
----------------- -------
asyncio-mqtt 0.16.1
easyconfig 0.2.8
paho-mqtt 1.6.1
pip 23.0.1
pydantic 1.10.4
pyserial 3.5
pyserial-asyncio 0.6
ruamel.yaml 0.17.21
ruamel.yaml.clib 0.2.7
setuptools 65.6.3
smllib 1.2
typing_extensions 4.4.0
wheel 0.38.4
New install sml2mqtt.git@rework:
================================
(venv) pi@smhogw1:~ $ python3 -m pip install git+https://github.com/spacemanspiff2007/sml2mqtt.git@rework
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting git+https://github.com/spacemanspiff2007/sml2mqtt.git@rework
Cloning https://github.com/spacemanspiff2007/sml2mqtt.git (to revision rework) to /tmp/pip-req-build-hq0bxtzh
Running command git clone --filter=blob:none --quiet https://github.com/spacemanspiff2007/sml2mqtt.git /tmp/pip-req-build-hq0bxtzh
Running command git checkout -b rework --track origin/rework
Zu neuem Branch 'rework' gewechselt
Branch 'rework' folgt nun Remote-Branch 'rework' von 'origin'.
Resolved https://github.com/spacemanspiff2007/sml2mqtt.git to commit 1e259f8f5b4ebe4c97ae94e4878adebd696242ac
Preparing metadata (setup.py) ... done
Requirement already satisfied: asyncio-mqtt==0.16.1 in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from sml2mqtt==1.2.2) (0.16.1)
Requirement already satisfied: pyserial-asyncio==0.6 in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from sml2mqtt==1.2.2) (0.6)
Requirement already satisfied: easyconfig==0.2.8 in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from sml2mqtt==1.2.2) (0.2.8)
Requirement already satisfied: pydantic<2.0,>=1.10 in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from sml2mqtt==1.2.2) (1.10.4)
Requirement already satisfied: smllib==1.2 in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from sml2mqtt==1.2.2) (1.2)
Requirement already satisfied: typing-extensions>=4.4.0 in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from asyncio-mqtt==0.16.1->sml2mqtt==1.2.2) (4.4.0)
Requirement already satisfied: paho-mqtt>=1.6.0 in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from asyncio-mqtt==0.16.1->sml2mqtt==1.2.2) (1.6.1)
Requirement already satisfied: ruamel.yaml<0.18,>=0.17 in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from easyconfig==0.2.8->sml2mqtt==1.2.2) (0.17.21)
Requirement already satisfied: pyserial in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from pyserial-asyncio==0.6->sml2mqtt==1.2.2) (3.5)
Requirement already satisfied: ruamel.yaml.clib>=0.2.6 in /opt/sml2mqtt/venv/lib/python3.8/site-packages (from ruamel.yaml<0.18,>=0.17->easyconfig==0.2.8->sml2mqtt==1.2.2) (0.2.7)
Building wheels for collected packages: sml2mqtt
Building wheel for sml2mqtt (setup.py) ... done
Created wheel for sml2mqtt: filename=sml2mqtt-1.2.2-py3-none-any.whl size=40639 sha256=f1f2c4d7a368154cb07769c10bbae37cbfd28d959dba953249db741f9ce0036f
Stored in directory: /tmp/pip-ephem-wheel-cache-oslm7rlh/wheels/c8/ac/3f/d4543904df0ab67422d0c6daf4c97ada068e55bbea2b7173ae
Successfully built sml2mqtt
Installing collected packages: sml2mqtt
Successfully installed sml2mqtt-1.2.2
Run Test sml2mqtt.git@rework:
=============================
(venv) pi@smhogw1:~ $ sml2mqtt -c /opt/sml2mqtt/config.yml -a
[2023-03-02 17:05:51,538] [sml ] INFO | Starting V1.2.2
[2023-03-02 17:05:51,545] [sml.ttyUSB0.status ] INFO | PORT_OPENED
[2023-03-02 17:05:52,555] [sml.ttyUSB0 ] INFO |
[2023-03-02 17:05:52,556] [sml.ttyUSB0 ] INFO | Received Frame
Check MQTT Broker Log:
======================
(venv) pi@smhogw1:~ $ sml2mqtt -c /opt/sml2mqtt/config.yml
2023-03-02T17:11:21: Saving in-memory database to /var/snap/mosquitto/common//mosquitto.db.
2023-03-02T17:38:11: New connection from 192.168.1.47:51731 on port 1883.
2023-03-02T17:38:11: New client connected from 192.168.1.47:51731 as smhogw1 (p2, c1, k60, u'shwguser').
Your command line with client-id is now ok! (smhogw1 (p2, c1, k60, u'shwguser'))
When will the new version be released?
I'll wait for feedback on the dockerfile from another user and fix some small remaining things e.g. in the docs.
In the meantime if you experience strange behavior (e.g. reconnect) just let me know.
Which Python library can you recommend for GPIO programming for the Raspberry Pi?
No idea - sorry.