433Mhz Etekcity Remote Outlet using remote_transmitter

I am hoping someone can help me figure out what I’m doing wrong trying to control a https://www.amazon.com/Etekcity-Household-Appliances-Unlimited-Connections/dp/B00DQELHBS with a Wemos D1 Mini Pro and 433 Transmitter.

I have code that works on using the Arduino IDE that proves that the transmitter works but I can’t seem to adapt it to work in ESPHome.

Here’s the working Arduino IDE code:

#include <RCSwitch.h>

// Array of ON/OFF codes. You must replace these with your codes obtained using a sniffer. This matches the 5 outlet remote.
unsigned long rc_codes[5][2] = {
  // ON     //OFF 
  {4478259, 4478268}, /* Outlet 1 */ 
  {4478403, 4478412}, /* Outlet 2 */
  {4478720, 4478732}, /* Outlet 3 */
  {4480259, 4480268}, /* Outlet 4 */
  {4486403, 4486412}, /* Outlet 5 */
};

// The physical Arduino PIN (this will be called with pinMode()). Change this according to your board layout
#define RC_PIN_TX D6

//––//

#define RC_PROTOCOL 1
#define RC_PULSE_LENGTH 190 // 'Delay', if you got the right codes and this isn't working, check that the delay/pulse length from the sniffer matches this
#define RC_BIT_LENGTH 24

RCSwitch sendSwitch = RCSwitch();

void setup()
{
  Serial.begin(9600);
  sendSwitch.enableTransmit(RC_PIN_TX);
  sendSwitch.setProtocol(RC_PROTOCOL); // defaults to 1 anyway
  sendSwitch.setPulseLength(RC_PULSE_LENGTH); // this is critical
}

void enableOutlet(int outletNumber, bool onOrOff)
{
  if (outletNumber < 1 || outletNumber > 5)
  {
    Serial.println("Invalid outlet number");
    return;
  }
  
  unsigned long *onOffCodes = rc_codes[outletNumber - 1];
  unsigned long codeToSend = onOffCodes[onOrOff ? 0 : 1];
  sendSwitch.send(codeToSend, RC_BIT_LENGTH);
  
  char outletNumberString[1];
  int retVal = snprintf(outletNumberString, 1, "%d", outletNumber);
  if (retVal < 0)
  {
    Serial.println("Log encoding error");
    return;
  }
  
  if (onOrOff)
  {
    Serial.print("Enabling");
  }
  else
  {
    Serial.print("Disabling");
  }
  
  Serial.print(" outlet ");
  Serial.println(outletNumberString);
}

void loop()
{
  delay(1000);
    enableOutlet(1, true);
  delay(1000);
    enableOutlet(1, false);
  enableOutlet(2, true);
  delay(1000);
  enableOutlet(2, false);
}

Here’s my YAML code.:

esphome:
  name: 433_remote_transmitter
  platform: ESP8266
  board: d1_mini_pro

wifi:
  ssid: "XXXX"
  password: "XXXX"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "433 Remote Transmitter"
    password: "c4FOmXCTDPJb"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

remote_transmitter:
  pin: D6
  carrier_duty_percent: 100%
  
# Individual switches
switch:
  - platform: template
    name: "Etekcity 01"
    turn_off_action:  
        remote_transmitter.transmit_rc_switch_raw:
            code: '010001000101010100110011'
            protocol: 1
            
    turn_off_action:  
        remote_transmitter.transmit_rc_switch_raw:
            code: '010001000101010100111100'
            protocol: 1

  - platform: template
    name: "Etekcity 02"
    turn_off_action:  
        remote_transmitter.transmit_rc_switch_raw:
            code: '010001000101010111000011'
            protocol: 1

    turn_off_action:  
        remote_transmitter.transmit_rc_switch_raw:
            code: '010001000101010111001100'
            protocol: 1

The logs say that it’s transmitting but the outlets are not responding.

I tried to change the protocol to:

protocol:
     pulse_length: 196

but that doesn’t seem to work either.

Any help is appreciated.

I’ve been trying to do the same thing with an esp8266 with no success. I have a transmitter and receiver working through a raspberry pi working just fine.

I’ve gone through the rpi-rf python library home assistant uses and verified all the information seems to be the same as what ESPHome is documenting.

I even put the transmitter wired to the esp near (almost on top of) the receiver I have on my pi, but it didn’t receive anything. Almost like ESPHome isn’t transmitting it when the switch is toggled for some reason. Not sure what to make of that.

The switch also doesn’t stay on, when toggled, in home assistant which I find odd for a switch.

Have you made any progress that might help out with this?

@DarthSebulba04 I have not made any progress. I figure at this point either there are only a few of us messing with 433 transmitters or others are using a totally different approach. I’m still hopeful someone will be able to provide some insight or suggestions.

I think I just found a solution after discovering this issue: https://github.com/esphome/issues/issues/1718

I added the config

          repeat:
            times: 2
            wait_time: 0s

and my test light seems to respond. I’m going to add my other outlets and see what happens.

EDIT: I had to make the wait_time 10ms for all of my outlets to work.

EDIT2: I found a repeat times of 10 and wait_time of 0s gave me the best results. This matches what the rpi-rf component uses.

Hope this helps!

I had the same issue. Just posted my solution here:
https://community.home-assistant.io/t/different-results-from-native-rc-switch-library-vs-esphomes-rc-switch-remote-receiver-for-433mhz-rf-signals/228976/5?u=unsplorer

Hope this helps!

1 Like