Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wbec generating different mqtt devices under fhem #125

Open
marc107 opened this issue Mar 17, 2024 · 8 comments
Open

wbec generating different mqtt devices under fhem #125

marc107 opened this issue Mar 17, 2024 · 8 comments

Comments

@marc107
Copy link

marc107 commented Mar 17, 2024

Hello everyone,

i have been using wbec in combination with mqtt and fhem for some time now and I noticed that several (over 100) mqtt devices have been created for wbec in fhem - see the following screenshot. Of course, the device with the highest consecutive number is always used, but deleting the more than 100 devices is not really fun.
Does anyone have an idea why new devices are always being created in autocreate? Apparently wbec always reports to the mqtt broker with a different name!

Greetings & thanks

Marc

image

@abuesen
Copy link

abuesen commented Mar 18, 2024

Hi Marc,

I'm using the Mosquitto MQTT-Brooker. That's fine, there is one topic wbec and one OpenWB published by the wbec. No different names here.

Does your wbec use a fixed IP in your network?

Regards, Andre.

Screenshot_20240318_165759

@marc107
Copy link
Author

marc107 commented Mar 20, 2024

Hi Andre,

thanks for your reply!
Yes, IP of wbec is fixed.
I have to explore the mqtt tomorrow, currently i don't know the newest topic generated @fhem. There are a lot... ;-)

@marc107
Copy link
Author

marc107 commented Mar 21, 2024

I did some searching and found out that the mqtt-server included in fhem creates a new device with every reconnect if no clientid is defined in the mqtt device (here the wbec).

Excerpt from the fhem help:
Most MQTT-capable devices contain options for assigning a unique ClientID (see the example of the zigbee2mqtt service above). If no ClientID is assigned, some clients use new IDs for each connection. It is recommended to make use of these setting options if possible.

Unfortunately I could not find the option, is it not included in wbec or does it have a different name?

@marc107
Copy link
Author

marc107 commented Mar 22, 2024

I have found a solution within fhem:
If you edit the readings list so that it looks like this afterwards, no new mqtt devices are created:

image

However, the question about the mqqt ClientID in wbec might still be interesting in general.

@steff393
Copy link
Owner

Hello, sorry, but I don't have further information about the MQTT client id.

@abuesen
Copy link

abuesen commented Mar 24, 2024

Hello, sorry, but I don't have further information about the MQTT client id.

Die Arduino-Library unterstützt eine ClientID: https://github.com/knolleary/pubsubclient
Dokumentiert in der API: https://pubsubclient.knolleary.net/api#connect

@steff393
Copy link
Owner

Danke für den Hinweis. Das hier dürfte es erklären:

wbec/src/mqtt.cpp

Lines 160 to 162 in 07a5855

// Create a random client ID
char clientId[10];
snprintf_P(clientId, sizeof(clientId), PSTR("wbec-%d"), (uint8_t)random(255));

con = client.connect(clientId, lastWillTopic, lastWillQos, lastWillRetain, lastWillMsgOff);

@steff393
Copy link
Owner

steff393 commented May 1, 2024

Ich lasse den Issue mal offen und baue künftig eine parametrierbare Client-ID ein: cfgMqttClientId
Wenn der Parameter 0 ist, dann wäre das Verhalten wie bisher (=random(255)). Ansonsten der eingestellte Wert.

@steff393 steff393 reopened this May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants