Controlling Two Sonoff CH4 Channels with One Switch

Hi everyone,

I’m trying to control two channels of a Sonoff CH4 device using just one switch in my OpenHAB setup. I’ve been experimenting with different approaches but haven’t quite got it working yet. Let me share what I’ve tried so far and see if anyone can help me figure this out!

My Current Setup

I have a Sonoff CH4 device with four channels, but I’m focusing on controlling channels 1 and 2 together. I want to be able to turn both channels on or off with a single switch in my sitemap. Here’s how I’ve set it up:

Item Configuration

I’ve defined two items for the channels:
plaintext
Switch sonoffpoolCH1 “SonOff Pool 4CH Ausgang 1” { mqtt=“>[mosquitto:cmnd/sonoffpool/POWER1:command::default], <[mosquitto:stat/sonoffpool/POWER1:state:default]" }
Switch sonoffpoolCH2 “SonOff Pool 4CH Ausgang 2” { mqtt=">[mosquitto:cmnd/sonoffpool/POWER2:command:
:default], <[mosquitto:stat/sonoffpool/POWER2:state:default]” }

Rule Configuration

I’ve created a rule to control both channels when the first switch is toggled:
plaintext
rule “sonoffpool”
when Item sonoffpoolCH1 received command
then
if (receivedCommand == ON) {
mqttActions.publishMQTT(“cmnd/sonoffpool/POWER1”, “1”)
mqttActions.publishMQTT(“cmnd/sonoffpool/POWER2”, “1”)
} else if (receivedCommand == OFF) {
mqttActions.publishMQTT(“cmnd/sonoffpool/POWER1”, “0”)
mqttActions.publishMQTT(“cmnd/sonoffpool/POWER2”, “0”)
}
end

The Problem

The issue I’m running into is that the rule isn’t executing both actions when the switch is toggled. It seems like only the first command is being sent, and the second one is being ignored. I’ve checked the logs, and there are no errors being reported, but the second channel isn’t responding as expected.

What I’ve Tried

  1. Separate Rules: I tried creating two separate rules, one for each channel, but that didn’t solve the problem. I still couldn’t control both channels with a single switch.
  2. Single Rule with Multiple Actions: I combined both actions into a single rule, thinking that might help, but I still only see one command being sent.
  3. Different Commands: I experimented with different command formats, but nothing seems to work consistently.

What I Need

I need a way to ensure that both channels are controlled simultaneously when the switch is toggled. Ideally, I’d like to keep the setup simple and avoid having to create multiple rules or items if possible.

Questions

  • Is there a better way to structure the rule so that both channels are controlled together?
  • Are there any common pitfalls I might be falling into with the MQTT binding?
  • Should I consider using a different approach altogether, like a custom UI element or a scene?

Any advice or suggestions would be greatly appreciated! I’m really looking forward to getting this working smoothly.

Best regards,
[Your Name]