Hi there,
I’m trying to control two channels of a sonoff ch4 device with only one button. So in the sitemap I only have one switch for controlling two channels at the same time.
My approaches till now:
1.)
Channel-1 via normal item (I think this does not work because of old syntax?):
Switch sonoffpoolCH1 "SonOff Pool 4CH Ausgang 1"
{ mqtt=">[mosquitto:cmnd/sonoffpool/POWER1:command:*:default],
<[mosquitto:stat/sonoffpool/POWER1:state:default]" }
only Channel-2 via rule:
rule "sonoffpool"
when
Item sonoffpoolCH1 received command
then
val mqttActions=getActions("mqtt","mqtt:broker:mosquitto")
switch (receivedCommand) {
case ON:
mqttActions.publishMQTT("cmnd/sonoffpool/POWER2", "1")
case OFF :
mqttActions.publishMQTT("cmnd/sonoffpool/POWER2", "0")
}
end
Only the rule fired, the switch statements gets ignored, no activity on MQTT Broker.
2.) Both actions in the rule:
rule "sonoffpool"
when
Item sonoffpoolCH1 received command
then
val mqttActions=getActions("mqtt","mqtt:broker:mosquitto")
switch (receivedCommand) {
case ON:
mqttActions.publishMQTT("cmnd/sonoffpool/POWER1", "1")
mqttActions.publishMQTT("cmnd/sonoffpool/POWER2", "1")
case OFF :
mqttActions.publishMQTT("cmnd/sonoffpool/POWER1", "0")
mqttActions.publishMQTT("cmnd/sonoffpool/POWER2", "0")
}
end
The rule does not load because of syntax errors. How can I separate the two actions in the switchcase so both are executed? Still no luck with simple “when” statements.
3.)
Copy the first rule with the other channel --> Only one Rule fired…
Could someone help me with this?
Thanks a lot