Setup Smart Plug from AISIRER

Hi guys,

I am using hassio since a while and most smart things are running now. However, I bought smart plugs from AISIRER (WiFi) recently and try to integrate them with basic features (on/off). I have the device_tracker running and the plugs have been added to known_devices.yaml

esp_68093c:
  hide_if_away: false
  icon: mdi:power-socket-eu
  mac: DC:4F:22:68:09:3C
  name: ESP-68093C
  picture:
  track: true

Well I could not find any help so far using google, youtube and this forum. Can anybody help me please?

Thank you in advance.

Patrick

So I tried now to connect the devices with ESPhome and used two tutorials I found:

How to get started with ESPHome and Sonoff
and with some research on this forum:

Well I think I setup all things according this tutorials but I am running into issues and need help from you guys. So I put the following code into ESPhome:

esphome:
  name: esp68016f
  platform: ESP8266
  board: esp8285

wifi:
  ssid: "SSID"
  password: "PW_WPA2"
  
  manual_ip:
    static_ip: $local.ip.plug
    gateway: $local.ip
    subnet: $subnet

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

time:
  - platform: homeassistant
    id: homeassistant_time

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO3
      inverted: True
    name: "esp68016f_button"

switch:
  - platform: gpio
    name: "esp68016f_Relay"
    pin: GPIO14
    restore_mode: ALWAYS_ON
  - platform: gpio
    name: "esp68016f_LED_Blue"
    pin: GPIO1
    inverted: True
    restore_mode: ALWAYS_OFF
  - platform: gpio
    name: "esp68016f_LED_Red"
    pin: GPIO13
    inverted: True
    restore_mode: ALWAYS_OFF
     
sensor:
  - platform: hlw8012
    sel_pin:
      number: GPIO12
      inverted: True
    cf_pin: GPIO04
    cf1_pin: GPIO05
    # Higher value gives lower watt readout
    current_resistor: 0.00221
    # Lower value gives lower voltage readout
    voltage_divider: 871
    current:
      name: "esp68016f_Amperage"
      unit_of_measurement: A
    voltage:
      name: "esp68016f_Voltage"
      unit_of_measurement: V
    power:
      name: "esp68016f_Wattage"
      unit_of_measurement: W
      id: "esp68016f_Wattage"
    change_mode_every: 8
    update_interval: 10s
  - platform: total_daily_energy
    name: "esp68016f_Total_Daily_Energy"
    power_id: "esp68016f_Wattage"
    filters:
        # Multiplication factor from W to kW is 0.001
        - multiply: 0.001
    unit_of_measurement: kWh
      
# Extra sensor to keep track of plug uptime
  - platform: uptime
    name: "esp68016f_Sensor"

Validation is successful. So the failure I get is:
ERROR Connecting to local.ip.plug:8266 failed: [Errno 111] Connection refused

Any idea?

Not sure if it is of value to mention: I tried to upload it when the plug was off and on. But I did not pressed any buttons on the device so far, so no RESET or maybe magic press for flashing the Plug.

Did you have any joy with this as I was thinking about buying some of these plug and hacking them with esphome as well.
Thanks

Hi, not so far. I thought the Community here would help to get the plugs visible much more quicker. I saw that some guys already flashed them but however I do not see the plugs been online and I do not know the magic trick. I will spend some time on it the next days and try to file a how to if I find the solution. Still if someone can help I appreciate any hints. Thanks

I’ve cobbled this together

# Naming substitutions
substitutions:
  devicename: powerplug1

esphome:
  name: ${devicename}
  platform: ESP8266
  board: esp8285

# WiFi connection
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.1.55
    gateway: 192.168.1.1
    subnet: 255.255.255.0
    dns1: 192.168.1.1
    dns2: 192.168.1.1
    
# Enable logging
logger:

# Enable Home Assistant API
api:
  password: !secret api_password

# Enable over-the-air updates
ota:
  password: !secret ota_password

# Enable Web server
web_server:
  port: 80


# Sync time with Home Assistant
time:
  - platform: homeassistant
    id: homeassistant_time

# Text sensors with general information
text_sensor:
  - platform: version
    name: ${devicename} version
  - platform: wifi_info
    ip_address:
      name: ${devicename} ip
    ssid:
      name: ${devicename} ssid
    bssid:
      name: ${devicename} bssid

sensor:
  # Uptime sensor
  - platform: uptime
    name: ${devicename} uptime
    filters:
      - lambda: return x / 3600;
    unit_of_measurement: "h"
  # WiFi Signal sensor
  - platform: wifi_signal
    name: ${devicename} wifi_signal
    update_interval: 10s

  # Power sensor
  - platform: hlw8012
    sel_pin:
      number: GPIO12
      inverted: true
    cf_pin: GPIO04
    cf1_pin: GPIO05
    change_mode_every: 3
    update_interval: 3s
    # Current sensor
    current:
      name: ${devicename} current
      unit_of_measurement: A
      accuracy_decimals: 3
      filters:
        # Map from sensor -> measured value
        - calibrate_linear:
            - 0.0 -> 0.013
            - 0.08208 -> 0.071
            - 1.34223 -> 1.066
            - 5.57170 -> 4.408
            - 6.69184 -> 5.259
            - 6.97187 -> 5.540
        # Make everything below 0.01A appear as just 0A.
        # Furthermore it corrects 0.013A for the power usage of the plug.
        - lambda: if (x < (0.01 - 0.013)) return 0; else return (x - 0.013);
    # Voltage sensor
    voltage:
      name: ${devicename} voltage
      unit_of_measurement: V
      accuracy_decimals: 1
      filters:
        # Map from sensor -> measured value
        - calibrate_linear:
            - 0.0 -> 0.0
            - 602.87506 -> 229.9
            - 609.8 -> 232.8
    # Power sensor
    power:
      id: power
      name: ${devicename} power
      unit_of_measurement: W
      accuracy_decimals: 0
      filters:
        # Map from sensor -> measured value
        - calibrate_linear:
            - 0.0 -> 1.14
            - 62.06167 -> 10.93
            - 1503.27161 -> 247.6
            - 1599.81213 -> 263.7
            - 3923.67700 -> 631.4
            - 7109.50928 -> 1148.0
            - 7237.0857 -> 1193.0
            - 7426.71338 -> 1217.0
        # Make everything below 2W appear as just 0W.
        # Furthermore it corrects 1.14W for the power usage of the plug.
        - lambda: if (x < (2 + 1.14)) return 0; else return (x - 1.14);
  # Total daily energy sensor
  - platform: total_daily_energy
    name: ${devicename} daily_energy
    power_id: power
    filters:
      # Multiplication factor from W to kW is 0.001
      - multiply: 0.001
    unit_of_measurement: kWh

binary_sensor:
  # Binary sensor for the button press
  - platform: gpio
    name: ${devicename} button
    pin:
      number: GPIO1
      inverted: true
    on_press:
      - switch.toggle: relay

switch:
  # Switch to restart the plug
  - platform: restart
    name: ${devicename} restart
  # Switch to toggle the relay
  - platform: gpio
    id: relay
    name: ${devicename} switch
    pin: GPIO14 # correct
    on_turn_on:
      - light.turn_on: led
    on_turn_off:
      - light.turn_off: led

output:
  # Relay state led
  - platform: esp8266_pwm
    id: state_led
    pin:
      number: GPIO13
      inverted: false

light:
  # Relay state light
  - platform: monochromatic
    output: state_led
    id: led

I’ve not fully tested it yet plus just to confirm these are the plugs I have https://www.amazon.co.uk/gp/product/B07N1G5Y5D/ref=ppx_yo_dt_b_asin_title_o05_s00?ie=UTF8&psc=1

Just to say I don’t think these plug can be flashed OTA anymore using tuya-convert as the firmware has been updated to stop it.

Please let me know how you get on.

Thanks

1 Like

Hi Egoman, I’m trying to set up my Aisirer plugs but while some of it works I have a feeling it differs from your set up a bit. I’ve got the plug working with Home Assistant but the core functionality of turning it on or off doesn’t work. The plug is currently behaving like a non-smart plug and is on all the time (although wifi etc works as well as the logger output).

Do you know how to find out which of the GPIO pins are correct or is it a case of trial and error?

My plug looks like this: Amazon link

I managed to get things working quite nicely thanks for Egoman’s work and switching out some pins. Here is my working yaml:

# Naming substitutions
substitutions:
  devicename: powerplug1
  # Higher value gives lower watt readout
  current_res: '0.00224'
  # Lower value gives lower voltage readout
  voltage_div: '948'

esphome:
  name: ${devicename}
  platform: ESP8266
  board: esp8285

# WiFi connection
wifi:
  ssid: '[your-ssid-here]'
  password: '[your-password-here]'
  manual_ip:
    static_ip: 192.168.1.92
    gateway: 192.168.1.1
    subnet: 255.255.255.0
    dns1: 192.168.1.1
    dns2: 192.168.1.1
  # Enable fallback hotspot
  ap:
    ssid: 'Powerplug1 Fallback Hotspot'
    password: '[your-password-here]'

captive_portal:

# Enable logging
logger:
  level: INFO

# Enable Home Assistant API
api:
  password: '[your-password-here]'

# Enable over-the-air updates
ota:
  password: '[your-password-here]'

# Enable Web server
web_server:
  port: 80

# Sync time with Home Assistant
time:
  - platform: homeassistant
    id: homeassistant_time

# Text sensors with general information
text_sensor:
  - platform: version
    name: ${devicename} version
  - platform: wifi_info
    ip_address:
      name: ${devicename} ip
    ssid:
      name: ${devicename} ssid
    bssid:
      name: ${devicename} bssid

sensor:
  # Uptime sensor
  - platform: uptime
    name: ${devicename} uptime
    filters:
      - lambda: return x / 3600;
    unit_of_measurement: 'h'
  # WiFi Signal sensor
  - platform: wifi_signal
    name: ${devicename} wifi_signal
    update_interval: 10s

  # Power sensor
  - platform: hlw8012
    sel_pin:
      number: GPIO12
      inverted: true
    cf_pin: GPIO05 #GPIO04
    cf1_pin: GPIO14 #GPIO05
    change_mode_every: 3
    update_interval: 3s
    current_resistor: ${current_res}
    voltage_divider: ${voltage_div}
    # Current sensor
    current:
      name: ${devicename} current
      unit_of_measurement: A
      accuracy_decimals: 3
      filters:
        # Map from sensor -> measured value
        - calibrate_linear:
            - 0.0 -> 0.013
            - 1.56 -> 2.97
        # Make everything below 0.01A appear as just 0A.
        # Furthermore it corrects 0.013A for the power usage of the plug.
        - lambda: if (x < (0.01 - 0.015)) return 0; else return (x - 0.013);
    # Voltage sensor
    voltage:
      name: ${devicename} voltage
      unit_of_measurement: V
      accuracy_decimals: 2
    # Power sensor
    power:
      id: power
      name: ${devicename} power
      unit_of_measurement: W
      accuracy_decimals: 2
  # Total daily energy sensor
  - platform: total_daily_energy
    name: ${devicename} daily_energy
    power_id: power
    filters:
      # Multiplication factor from W to kW is 0.001
      - multiply: 0.001
    unit_of_measurement: kWh

binary_sensor:
  # Binary sensor for the button press
  - platform: gpio
    name: ${devicename} button
    pin:
      number: GPIO13
      inverted: true
    on_press:
      - switch.toggle: relay

switch:
  # Switch to restart the plug
  - platform: restart
    name: ${devicename} restart
  # Switch to toggle the relay
  - platform: gpio
    id: relay
    name: ${devicename} switch
    pin: GPIO15
    on_turn_on:
      - light.turn_on: led
    on_turn_off:
      - light.turn_off: led

output:
  # Relay state led
  - platform: esp8266_pwm
    id: state_led
    pin:
      number: GPIO2
      inverted: true

light:
  # Relay state light
  - platform: monochromatic
    output: state_led
    id: led

This is for the plugs linked to above

1 Like

Hello - sorry for the slow response but I’m glad you got it working.