iobroker-community-adapters / ioBroker.mqtt-client

Publish and subscribe ioBroker states to MQTT Brokers
MIT License
11 stars 10 forks source link

States written twice when globally subscribed and also available as state option #385

Open HSE83 opened 2 days ago

HSE83 commented 2 days ago

Describe the bug
When I turn on a subscription to all topics ("#"), every state gets updated twice - even if QOS 2 is configured. Messages seem to be received twice from mqtt module (see log further down).

To Reproduce
Let the adapter run to gather various topics and have it create states from them. Enable MQTT subscription for a state. Ensure the global subscription of # is enabled. Once the state is written (updated via mqtt), the data is written twice. This can be seen by subscribing the state e.g. from the Javascript adapter in mode "any update" (on function with {id: '......'} ). When I disable the global subscription of # again, the state is again only written once per mqtt update.

Expected behavior
Each state is only to be updated with the same data once, even if an additional global subscription is active.

Screenshots & Logfiles

2024-10-19 23:04:27.757  - debug: mqtt-client.0 (5027) received message 0 for id mqtt-client.0.dusty_relais.fcc6ec.r1.status=>{"enabled":true,"publish":false,"pubChangesOnly":false,"pubAsObject":false,"qos":0,"retain":false,"subscribe":true,"subChangesOnly":false,"subAsObject":false,"subQos":2,"setAck":false,"topic":"dusty_relais/fcc6ec/r1/status","type":"string","state":{"val":"0","ack":false,"ts":1729371862767,"q":0,"from":"system.adapter.mqtt-client.0","user":"system.user.admin","lc":1728393640416}}
2024-10-19 23:04:27.758  - debug: mqtt-client.0 (5027) received message 0 for id mqtt-client.0.dusty_relais.fcc6ec.r1.status=>{"enabled":true,"publish":false,"pubChangesOnly":false,"pubAsObject":false,"qos":0,"retain":false,"subscribe":true,"subChangesOnly":false,"subAsObject":false,"subQos":2,"setAck":false,"topic":"dusty_relais/fcc6ec/r1/status","type":"string","state":{"val":"0","ack":false,"ts":1729371862767,"q":0,"from":"system.adapter.mqtt-client.0","user":"system.user.admin","lc":1728393640416}}

Versions:

Further information "On change" on the state is turned off and cannot be used (the state represents the last key pressed on a keypad. If the state is updated via mqtt, it must also be updated in iobroker exactly once. Otherwise keys would not be recognized or recognized twice).

Apollon77 commented 1 day ago

Can you please add a full debug los which shows this? Please also enable the advanced logging in the adapter settings