arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.12k stars 4.79k forks source link

SwitchTopic for Switch5, 6, 7 not right #3301

Closed brainnex closed 6 years ago

brainnex commented 6 years ago

I configured 2 switches: switch4 and switch5. Switch4 is sending the right MQTT message: 15:15:36 MQT: cmnd/sonoff_test1/POWER4 = ON

but Switch5, 6, 7 are sending by identical configuration to Switch4: 15:15:36 MQT: domoticz/in = {"command":"switchlight","idx":0,"switchcmd":"On"}

To Reproduce Configure Switch4 and 5. set:

SwitchMode4 1
SwitchMode5 1
SwitchTopic 1

Toggle Switch4 and 5 an watch different output in console

Expected behavior same output as switch4

tonyjobson commented 6 years ago

Jumping on the back of this issue. I also have the same / similar problem.

NodeMCU board. Tasmota 6.1.1c flashed. I have the board in a housing with 8 push to make switches. I want to use this device to trigger HA actions.

I've set D1 to D4 as switch 1-4 I've set D5-D7 as switch 5-7 I've set D0 to switch 8.

I can see the MQTT messages coming through for every switch but every message has the same messages content. stat/remote01/POWER OFF stat/remote01/RESULT {"POWER":"OFF"}

Nowhere in my MQTT messages is it indicating which switch the message is about.

I've compared this to my Sonos Duals and this allows me to set an MQTT friendly name. Is there anyway to set this for a generic device?

tonyjobson commented 6 years ago

I've worked around my issue by using rules to publish MQTT messages i can pick up based on the switch i'm hitting. maybe this could work for others.

for me I've created a rule using

"rule on switch1#state do publish /stat/remote2/switch1 endon on switch2#state do publish /stat/remote2/switch2 endon on switch3#state do publish /stat/remote2/switch3 endon on switch4#state do publish /stat/remote2/switch4 endon on switch5#state do publish /stat/remote2/switch5 endon on switch6#state do publish /stat/remote2/switch6 endon on switch7#state do publish /stat/remote2/switch7 endon on switch8#state do publish /stat/remote2/switch8 endon "

I then had to enable rules by entering "rule1 on" then they worked.

brainnex maybe this work around will help until the bug can be investigated?

brainnex commented 6 years ago

thanks for sharing your solution.

bikemike commented 6 years ago

Looks like this is a bug in the DomoticzSendKey function:

I added the following to the top of the function to fix the issue:

if (device > MAX_DOMOTICZ_IDX) return 0;

bikemike commented 6 years ago

And I see that it has been fixed in the development branch (5372cdf511bf8d90e35a335d26983a9edada220b)

ascillato commented 6 years ago

Hi

If your issue is solved, please close it. Thanks.

brainnex commented 6 years ago

thanks @arendst for fixing this and the others for help