Ok, i will try to explain it a little bit better...
I have connected two relays on a ESP-01.
Relay_1 is connected to GPIO 2
Relay_2 is connected to GPIO 0
In the sketch i declared:
int relay_pin1 = 2;
int relay_pin2 = 0;
Later in the sketch i got this part:
if ((char)payload[0] == '0' || message == "false") {
digitalWrite(relay_pin1, LOW);
Serial.println("relay_pin1 -> LOW");
relayState1 = LOW;
EEPROM.write(0, relayState1);
EEPROM.commit();
} else if ((char)payload[0] == '1' || message == "true") {
digitalWrite(relay_pin1, HIGH);
Serial.println("relay_pin1 -> HIGH");
relayState1 = LOW;
EEPROM.write(0, relayState1);
EEPROM.commit();
}
So actually it's like this:
when i send a payload with "0" or "false" the Relay_1 (GPIO 2) will be turned off.
when i send a payload with "1" or "true" the Relay_1 (GPIO 2) will be turned on.
That's good so far...
Farther the sketch contains this part for Relay_2:
else if ((char)payload[0] == '2') {
digitalWrite(relay_pin2, LOW);
Serial.println("relay_pin2 -> LOW");
relayState2 = LOW;
EEPROM.write(1, relayState2);
EEPROM.commit();
} else if ((char)payload[0] == '3') {
digitalWrite(relay_pin2, HIGH);
Serial.println("relay_pin2 -> HIGH");
relayState2 = HIGH;
EEPROM.write(1, relayState2);
EEPROM.commit();
}
So,
when i send a payload with "2" the Relay_2 (GPIO 0) will be turned off.
when i send a payload with "3" the Relay_2 (GPIO 0) will be turned on.
If i would implement the - || message == "false" - part to the payload of Relay_2 it would be the following scenario:
when i send a payload with "0" the Relay_1 (GPIO 2) will be turned off.
when i send a payload with "1" the Relay_1 (GPIO 2) will be turned on.
when i send a payload with "2" the Relay_2 (GPIO 0) will be turned off.
when i send a payload with "3" the Relay_2 (GPIO 0) will be turned on.
when i send a payload with "false" both relays (GPIO 0 and 2) will be turned off.
when i send a payload with "true" both relays (GPIO 0 and 2) will be turned on.
Because the problem is, that both parts of the Sketch would react on the "true" and "false" payload.
Unfortunately the iPhone just sends one true/false per click in the HomeKit app.
As i wrote its all connected via ioBroker on a Raspberry.
So the question is, if there is a possibility to distinguish the "true" for Relay_1 and the "true" for Relay_2...
It would be always the same payload... i know... ![]()
Seems not possible i think...