Alfawise PE1004T

Hi,
I’m kind of new with esphome and have hard time to understand how to get the leds working on my wifi plug. Could some one help with this?

There are two GPIOs, I think that is in used for the leds(red light and green light). Found some information from a Russian webpage:
GPIO4 is green led
GPIO5 is red led

With my yaml even the red does not work at all, button and relay works fine.
Would like to have it like this:

  • When plug is ON green led would be on.
  • When plug if OFF red led would be on.

Here is my yaml file:

esphome:
  name: indoor_wifi_plug_2
  platform: ESP8266
  board: esp8285

wifi:
  ssid: ""
  password: ""

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

captive_portal:

# Enable logging
logger:

# Enable Web Server (optional)
web_server:
  port: 80
  
# Enable Home Assistant API
api:

ota:

# Text sensors with general information
text_sensor:
  - platform: version
    name: indoor_wifi_plug_2_version
  - platform: wifi_info
    ip_address:
      name: indoor_wifi_plug_2_ip
    ssid:
      name: indoor_wifi_plug_2_ssid
    bssid:
      name: indoor_wifi_plug_2_bssid

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO13
      mode: INPUT_PULLUP
      inverted: true
    name: “indoor_wifi_plug_2 Power Button"
    on_press:
      - switch.toggle: relay

  - platform: status
    name: “indoor_wifi_plug_2 Status"

switch:
  - platform: gpio
    id: red_led
    pin:
      number: GPIO4
      inverted: true
    #restore_mode: ALWAYS_OFF

  - platform: gpio
    name: “indoor_wifi_plug_2"
    pin: GPIO12
    id: relay

sensor:
  # Uptime sensor
  - platform: uptime
    name: indoor_wifi_plug_2_uptime
  # WiFi Signal sensor
  - platform: wifi_signal
    name: indoor_wifi_plug_2_wifi_signal
    update_interval: 10s
    
time:
  - platform: homeassistant
    id: homeassistant_time

this is my config:

binary_sensor:
- platform: gpio
  pin:
    number: GPIO13
    mode: INPUT_PULLUP
    inverted: true
  name: "aw1004_ec4f54 button"
  on_press:
    - switch.toggle: relay
   
switch:
- platform: restart
  name: "aw1004_ec4f54 restart"
  
- platform: gpio
  name: "aw1004_ec4f54 outlet"
  icon: "mdi:power-socket"
  pin: GPIO12
  id: relay
  on_turn_on:
    then:
      - output.turn_on: gpio4
  on_turn_off:
    then:
      - output.turn_off: gpio4

status_led:
  pin:
    number: GPIO5
    inverted: true
    
output:
- platform: esp8266_pwm
  id: gpio4
  pin: GPIO4
  inverted: True

when I press the button (ON), green LED goes on
when I press the button again (OFF), green LED goes off

2 Likes

Great… I got it now working. Thanks for your help!!!

How do you add this Alfawise smart plug device to Home Assistant in a local way?

I have installed esphome on them with tuya convert. Worked fine at least with old firmwares on them. Don’t upgrade any official firmwares on them, if you have might be that tuya convert does not work. I guess in that case you need to open them up and use some soldering to be able to flash them with esphome.