ESPHome Blitzwolf SHP2 configurations

I have a couple of Blitzwolf SHP2’s and I noticed that they are different from each other. So these are my configuration files. The difference is in the GPIO numbers.

First configuration:

substitutions:
  plug_name: switchbw_1
  plug_ip: !secret switchbw_1_ip
# only change upper plug_name and plug_ip  
# put a secret.yaml file in the map with switchbw_1.yaml
  plug_gw: !secret gw
  plug_nm: !secret nm
  plug_dns_1: !secret dns_1
  plug_dns_2: !secret dns_2
  wifi_ssid: !secret wifi_name
  wifi_password: !secret wifi_code
  current_res: "0.00221"
  voltage_div: "955"
  api_pw: !secret api_password
  ota_pw: !secret ota_password

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

wifi:
  ssid: ${wifi_ssid}
  password: ${wifi_password}
  domain: .thuis
  manual_ip:
    static_ip: ${plug_ip}
    gateway: ${plug_gw}
    subnet: ${plug_nm}
    dns1: ${plug_dns_1}
    dns2: ${plug_dns_2}
    
# Enable logging
logger:

# Enable Web server
#web_server:
#  port: 80

# Enable Home Assistant API
api:
  password: ${api_pw}

ota:
  password: ${ota_pw}

time:
  - platform: homeassistant
    id: homeassistant_time
    
binary_sensor:
  - platform: gpio
    name: ${plug_name}_button
    pin:
      number: GPIO13
      mode: INPUT_PULLUP
      inverted: True
    on_press:
      - switch.toggle: relay
  - platform: status
    name: ${plug_name}_Status

switch:
  - platform: gpio
    id: relay
    name: ${plug_name}_Relay
    icon: mdi:power-socket-eu
    restore_mode: ALWAYS_ON
    pin: GPIO15
    on_turn_on:
      - switch.turn_on: blue_led
    on_turn_off:
      - switch.turn_off: blue_led

  - platform: gpio
    id: blue_led
    name: ${plug_name}_LED_Blue
    icon: mdi:led-on
    restore_mode: ALWAYS_ON
    pin: 
      number: GPIO02
      inverted: True

  - platform: gpio
    id: red_led
    name: ${plug_name}_LED_Red
    icon: mdi:led-on
    restore_mode: ALWAYS_OFF
    pin: 
      number: GPIO00
      inverted: True

sensor:
  - platform: hlw8012
    sel_pin:
      number: GPIO12
      inverted: True
    cf_pin: GPIO05
    cf1_pin: GPIO14
    current_resistor: ${current_res}
    voltage_divider: ${voltage_div}
    current:
      name: ${plug_name}_Amperage
      icon: mdi:current-ac
      unit_of_measurement: A
    voltage:
      name: ${plug_name}_Voltage
      icon: mdi:flash-circle
      unit_of_measurement: V
    power:
      name: ${plug_name}_Wattage
      icon: mdi:flash-outline
      unit_of_measurement: W
      id: ${plug_name}_Wattage
    change_mode_every: 8
    update_interval: 10s

  - platform: total_daily_energy
    name: ${plug_name}_Total Daily Energy
    icon: mdi:circle-slice-3
    power_id: ${plug_name}_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: ${plug_name}_Uptime_Sensor

  - platform: wifi_signal
    name: ${plug_name}_Wi-Fi_Signal
    update_interval: 60s

text_sensor:
  - platform: version
    name: ${plug_name}_firmware_version

Alternative configuration:

substitutions:
  plug_name: switchbw_6
  plug_ip: !secret switchbw_6_ip
# only change upper plug_name and plug_ip
# put a secret.yaml file in the map with switchbw_6.yaml
  plug_gw: !secret gw
  plug_nm: !secret nm
  plug_dns_1: !secret dns_1
  plug_dns_2: !secret dns_2
  wifi_ssid: !secret wifi_name
  wifi_password: !secret wifi_code
  current_res: "0.00221"
  voltage_div: "955"
  api_pw: !secret api_password
  ota_pw: !secret ota_password

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

wifi:
  ssid: ${wifi_ssid}
  password: ${wifi_password}
  domain: .thuis
  manual_ip:
    static_ip: ${plug_ip}
    gateway: ${plug_gw}
    subnet: ${plug_nm}
    dns1: ${plug_dns_1}
    dns2: ${plug_dns_2}
    
# Enable logging
logger:

# Enable Web server
#web_server:
#  port: 80

# Enable Home Assistant API
api:
  password: ${api_pw}

ota:
  password: ${ota_pw}

time:
  - platform: homeassistant
    id: homeassistant_time
    
binary_sensor:
  - platform: gpio
    name: ${plug_name}_button
    pin:
      number: GPIO3
      mode: INPUT_PULLUP
      inverted: True
    on_press:
      - switch.toggle: relay
  - platform: status
    name: ${plug_name}_Status

switch:
  - platform: gpio
    id: relay
    name: ${plug_name}_Relay
    icon: mdi:power-socket-eu
    restore_mode: ALWAYS_ON
    pin: GPIO14
    on_turn_on:
      - switch.turn_on: blue_led
    on_turn_off:
      - switch.turn_off: blue_led

  - platform: gpio
    id: blue_led
    name: ${plug_name}_LED_Blue
    icon: mdi:led-on
    restore_mode: ALWAYS_ON
    pin: 
      number: GPIO1
      inverted: True

  - platform: gpio
    id: red_led
    name: ${plug_name}_LED_Red
    icon: mdi:led-on
    restore_mode: ALWAYS_OFF
    pin: 
      number: GPIO13
      inverted: True

sensor:
  - platform: hlw8012
    sel_pin:
      number: GPIO12
      inverted: True
    cf_pin: GPIO04
    cf1_pin: GPIO05
    current_resistor: ${current_res}
    voltage_divider: ${voltage_div}
    current:
      name: ${plug_name}_Amperage
      icon: mdi:current-ac
      unit_of_measurement: A
    voltage:
      name: ${plug_name}_Voltage
      icon: mdi:flash-circle
      unit_of_measurement: V
    power:
      name: ${plug_name}_Wattage
      icon: mdi:flash-outline
      unit_of_measurement: W
      id: ${plug_name}_Wattage
    change_mode_every: 8
    update_interval: 10s

  - platform: total_daily_energy
    name: ${plug_name}_Total Daily Energy
    icon: mdi:circle-slice-3
    power_id: ${plug_name}_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: ${plug_name}_Uptime_Sensor

  - platform: wifi_signal
    name: ${plug_name}_Wi-Fi_Signal
    update_interval: 60s

text_sensor:
  - platform: version
    name: ${plug_name}_firmware_version

And my lovelace configuration that goes with it:

cards:
  - entities:
      - entity: switch.switchbw_1_relay
      - entity: sensor.switchbw_1_total_daily_energy
      - entity: sensor.switchbw_1_voltage
      - entity: sensor.switchbw_1_amperage
      - entity: sensor.switchbw_1_wattage
      - entity: switch.switchbw_1_led_blue
      - entity: switch.switchbw_1_led_red
      - entity: sensor.switchbw_1_uptime_sensor
      - entity: binary_sensor.switchbw_1_status
      - entity: sensor.switchbw_1_wi_fi_signal
      - entity: sensor.switchbw_1_firmware_version
    show_header_toggle: false
    style: |
      ha-card {
        --paper-card-background-color: rgba(255,255,255,0.1);
      }
    title: Blitzwolf 01 - Wasdroger
    type: entities
  - animate: true
    entities:
      - entity: sensor.switchbw_1_wattage
        name: Huidig vermogen
        show_state: true
      - entity: sensor.switchbw_1_total_daily_energy
        name: 24-uurs verbruik
        show_state: true
    hour24: true
    hours_to_show: 4
    labels: true
    legend: true
    line_color: '#a861ba'
    line_width: 2
    name: Verbruik wasdroger - 24 uur
    points_per_hour: 24
    style: |
      ha-card {
        --paper-card-background-color: rgba(255,255,255,0.1);
      }
    type: 'custom:mini-graph-card'
type: 'custom:vertical-stack-in-card'
8 Likes

Thanks for taking the time to document this!

Was struggling with my Teckin SP23 until I finally found your post detailing the GPIO pinouts!

1 Like

You’re welcome!

Hi there!
I’ve just registered to say thank you for this. very nice.

Though I have a question, is there a way to have the total energy sensor? This is important so that the utility_meter component can work and calculate the “today, yesterday, this week, last week, etc” energy sums.

1 Like

Hi Andrew. For as I know there is no total energy sensor or attribute. You probably have to create your own sensor.

Thanks!
Actually I found out that the utility meter component works the same way with a daily energy counter, which solves my problem :slight_smile: