letscontrolit / ESPEasy

Easy MultiSensor device based on ESP8266/ESP32
http://www.espeasy.com
Other
3.3k stars 2.22k forks source link

P001 Switch plugin and MQTT problem #5170

Closed tomatos-st closed 1 day ago

tomatos-st commented 1 day ago

I have a problem with communication via MQTT (with Domoticz) At first I detected strange "couplings": I turn on one GPIO and another one turns off additionally. I created new switches in Domoticz and made a set "Switch input - Switch" in tasks 1-11 and started to find. Here's what I got: Dom 744 SW 744

if I do task1 GPIO-0, Task 2, GPIO-1... Task 11 GPIO-10 in sequence is ok, but when I shuffle it starts to get interesting..

After analysis, it turns out that the task number is confused with the port number: and so, for example: MQTT:744 is on task 7 and instead of turning on the assigned port, it turns on the GPIO-6 port (task number -1 - ports are numbered from 0 and tasks from 1)... and so on

tonhuisman commented 1 day ago

After analysis, it turns out that the task number is confused with the port number: and so, for example: MQTT:744 is on task 7 and instead of turning on the assigned port, it turns on the GPIO-6 port (task number -1 - ports are numbered from 0 and tasks from 1)... and so on

I'm already working on the MQTT plugins, so I'll have a look at this issue.

TD-er commented 1 day ago

Hmm I don't think I really see what is going wrong here. However I do know that updating switch states from Domoticz is really hard to get it right, without using the Domoticz MQTT helper: https://espeasy.readthedocs.io/en/latest/Plugin/P029.html#p029-page

Can you try with 1 switch and this helper to see if it does fix your issues?

If this is not the fix, then it could also be related to recent changes in Domoticz. Are you using a recent version of Domoticz, or is it an already older version of Domoticz?

Edit: Hmm while posting my reply I see Ton already pushed a possible fix, so maybe first try his fix first...

Edit2: Just looked at Ton's changes and I think it was a bug I introduced... :(

tonhuisman commented 1 day ago

Test build available from this Actions run

tomatos-st commented 1 day ago

It works :) Just so you know how much I struggled before I figured out what was wrong, I was looking for connections in Domoticz (rules, conditions, events, connections), nothing suited me, I wasted a whole day :(

I'm going to bed. :)

TD-er commented 1 day ago

I'm going to bed. :)

Me too :) Thanks for reporting