(Sorry, I changed this commend now to the final version)
I got it running, thanks for your help!
My String Items are defined as follows now
String Sonoff_Basic_01_POWER1_String {mqtt="<[mosquitto:cmnd/sonoff-basic-01-switch/POWER1:command:TOGGLE]"}
String Sonoff_Basic_01_POWER2_String {mqtt="<[mosquitto:cmnd/sonoff-basic-01-switch/POWER2:command:TOGGLE]"}
So the rules can trigger now the command TOGGLE. My switches
Switch Wohnzimmer_Licht_Sofa "Wohnzimmerlicht Eins" <light> ["Lighting"] {mqtt=">[mosquitto:cmnd/sonoff-basic-01/power:command:*:default],<[mosquitto:stat/sonoff-basic-01/POWER:state:default]"}
Switch Wohnzimmer_Leselampe "Leselampe" <light> ["Lighting"] {mqtt=">[mosquitto:cmnd/sonoff-S20-01/power:command:*:default],<[mosquitto:stat/sonoff-S20-01/POWER:state:default]"}
are being switched now by the following rules
rule "sonoff-basic-01-switch POWER1"
when
Item Sonoff_Basic_01_POWER1_String received command TOGGLE
then
if(Wohnzimmer_Licht_Sofa.state == ON) sendCommand(Wohnzimmer_Licht_Sofa, OFF)
else sendCommand(Wohnzimmer_Licht_Sofa, ON)
end
rule "sonoff-basic-01-switch POWER2"
when
Item Sonoff_Basic_01_POWER2_String received command TOGGLE
then
if(Wohnzimmer_Leselampe.state == ON) sendCommand(Wohnzimmer_Leselampe, OFF)
else sendCommand(Wohnzimmer_Leselampe, ON)
end
What still did not work, is sending the mqtt command directly by the “publish” method. Do you have an idea what is wrong with my binding?