Esphome and Blitzwolf SHP5?

This is what I came up with, but I don´t have any device to test it on yet.

Edit 1: GPIO5 for USB-relay, Jaba comment
Edit 2: Logger and Uart conflict, bramschats comment

#############################################
#                                           #
#                 BW-SHP5                   #
#                                           #
#############################################
substitutions:
  plug_name: ESP_SHP5_01

esphome:
  name: ${plug_name}
  platform: ESP8266
  board: esp8285
  on_boot:
    priority: -10
    # Turn on switch during startup
    then:
      - switch.turn_on: relay

wifi:
  ssid: "ABCD1234"
  password: "ABCD1234"
  fast_connect: on

# Enable logging
logger:
  baud_rate: 0

# Enable Home Assistant API
api:
  password: "ABCD1234"
  reboot_timeout: 12h

ota:
  password: "ABCD1234"

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

# Text sensors with general information
text_sensor:
  - platform: version
    name: ${plug_name}_version
  - platform: wifi_info
    ip_address:
      name: ${plug_name}_ip
    ssid:
      name: ${plug_name}_ssid

uart:
  rx_pin: RX
  baud_rate: 4800

sensor:
  # Uptime sensor
  - platform: uptime
    name: ${plug_name}_uptime
  # WiFi Signal sensor
  - platform: wifi_signal
    name: ${plug_name}_wifi_signal
    update_interval: 30s
  # Power sensor
  - platform: cse7766
    update_interval: 10s
    # Current sensor
    current:
      name: ${plug_name}_current
      unit_of_measurement: A
      accuracy_decimals: 3
      filters:
        # Map from sensor -> measured value
        - calibrate_linear:
            - 0.0 -> 0.0
            - 1.0 -> 1.0
            - 2.0 -> 2.0
            - 3.0 -> 3.0
            - 4.0 -> 4.0
            - 5.0 -> 5.0
        # 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: ${plug_name}_voltage
      unit_of_measurement: V
      accuracy_decimals: 2
      filters:
        # Map from sensor -> measured value
        - calibrate_linear:
            - 0.0 -> 0.0
            - 100.0 -> 100.0
            - 200.0 -> 200.0
            - 300.0 -> 300.0
            - 400.0 -> 400.0
            - 500.0 -> 500.0
    # Power sensor
    power:
      id: power
      name: ${plug_name}_power
      unit_of_measurement: W
      accuracy_decimals: 1
      filters:
        # Map from sensor -> measured value
        - calibrate_linear:
            - 0.0 -> 0.0
            - 1000.0 -> 1000.0
            - 2000.0 -> 2000.0
            - 3000.0 -> 3000.0
            - 4000.0 -> 4000.0
            - 5000.0 -> 5000.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: ${plug_name}_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: ${plug_name}_button
    pin:
      number: GPIO16
      inverted: true
    on_press:
      - switch.toggle: relay

switch:
  # Switch to toggle the relay (Power output)
  - platform: gpio
    id: relay
    name: ${plug_name}_switch
    pin: GPIO14
    on_turn_on:
      - light.turn_on: led
    on_turn_off:
      - light.turn_off: led

  # Switch to toggle the relay (USB output)
  - platform: gpio
    id: relay2
    name: ${plug_name}_USB_switch
    pin: GPIO5
    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: GPIO00
      inverted: true

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

# Uses the red LED as a status indicator
status_led:
  pin:
    number: GPIO02
    inverted: true
2 Likes