Working config for Blitzwolf BW-SHP7!

I finally got the last few bits working.
The Blitzwolf BW-SHP7 is a dual socket with powermonitoring, it has a button for each socket, and three controllable LED’s (one for each socket and a status).

substitutions:
  device_name: shp7
  # Higher value gives lower watt readout
  current_res: '0.002291'
  # Lower value gives lower voltage readout
  voltage_div: '940'
  # BW-SHP7, dual outlet with powermonitoring.
  # One button for each relay, and one red led for each relay, as well as a blue status led
  # Static IP is configured, and fast_connect is enabled, as the SSID is hidden
  # Webserver is active and pw protected, and the OTA is password protected

esphome:
  name: '${device_name}'
  platform: ESP8266
  board: esp8285
  on_boot:
    then:
      - switch.turn_on: relay1
#      - switch.turn_on: relay2
      
wifi:
  ssid: !secret wifissid
  password: !secret wifipw
#  reboot_timeout: 60min
  manual_ip:
    static_ip: 192.168.1.100
    gateway: 192.168.1.1
    subnet: 255.255.255.0
  fast_connect: true
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${device_name} Hotspot"
    password: !secret appw

logger:
  baud_rate: 0

web_server:
  port: 80
  auth:
    username: !secret webuser
    password: !secret webpw

api:

ota:
  password: !secret otapw

time:
  - platform: homeassistant
    id: homeassistant_time

text_sensor:
  - platform: version
    name: "${device_name} ESPHome Version"
  - platform: wifi_info
    ip_address:
      name: "${device_name} ip"
    ssid:
      name: "${device_name} ssid"

binary_sensor:
  - platform: gpio
    id: button1
    name: button1
    internal: true
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: true
    on_press:
      - switch.toggle: relay1
  - platform: gpio
    id: button2
    name: button2
    internal: true
    pin:
      number: GPIO12
      mode: INPUT_PULLUP
      inverted: true
    on_press:
      - switch.toggle: relay2

output:
   - platform: esp8266_pwm
     id: led1
     pin:
       number: GPIO13
       inverted: true
   - platform: esp8266_pwm
     id: led2
     pin:
       number: GPIO2
       inverted: true

switch:
  - platform: gpio
    pin: GPIO14
    id: relay1
    name: 'relay1'
    on_turn_on:
      - output.turn_on: led1
    on_turn_off:
      - output.turn_off: led1
  - platform: gpio
    pin: GPIO16
    id: relay2
    name: 'relay2'
    on_turn_on:
      - output.turn_on: led2
    on_turn_off:
      - output.turn_off: led2

status_led:
  pin:
    number: GPIO01
    inverted: true

sensor:
  - platform: wifi_signal
    name: '${device_name} wifi signal'
    update_interval: 60s
    accuracy_decimals: 0
  - platform: uptime
    name: '${device_name} uptime'
    unit_of_measurement: days
    update_interval: 300s
    accuracy_decimals: 1
    filters:
      - multiply: 0.000011574
  - platform: hlw8012
    sel_pin:
      number: GPIO03
      inverted: true
    cf_pin: GPIO04
    cf1_pin: GPIO05
    current_resistor: ${current_res}
    voltage_divider: ${voltage_div}
    current:
      name: '${device_name} current'
      unit_of_measurement: 'A'
      accuracy_decimals: 3
      icon: mdi:flash-outline
    voltage:
      name: '${device_name} voltage'
      unit_of_measurement: 'V'
      icon: mdi:flash-outline
    power:
      name: '${device_name} power'
      unit_of_measurement: 'kW'
      id: power
      accuracy_decimals: 3
      filters:
        - multiply: 0.001
      icon: mdi:flash-outline
    change_mode_every: 4
    update_interval: 10s
  - platform: total_daily_energy
    name: '${device_name} daily energy'
    power_id: power
    unit_of_measurement: kWh
    accuracy_decimals: 5

Please add to https://esphome-configs.io/

1 Like

Ahh, yes of course, will do! :slight_smile:

Hi Fribert,

l ordered SHP7 and then I have found this topic. I didn’t receive it yet but I am trying to prepare everything to set it up. I am doing this first time and I don’t want to break something, so I apologize in advance if I will ask something stupid :slight_smile:
I instaled ESPHome addon in home assistant and created node for SHP7.
My first question is should I pick a “Generic ESP8266” for device type? I picked that one for testing now. Then I deleted everything in “Edit” and I pasted your script here (so here is completly and only your script).
I created secrets.yaml file and edited it with secrets until I pass validation.
Should I change anything else in your script? What about static_ip, should I change it?
Aha I see I am getting this warning in log, so I guess I will have to set a fixed IP for that device in router (when I’ll get it)?
“WARNING Initial connection failed. The ESP might not be connected to WiFi yet (Error connecting to 192.168.1.100: [Errno 113] No route to host). Re-Trying in 1 seconds”

What username and passwords are for “web_server”? Are they for home assistant (I don’t have any others)?

Anything else?

Thank you :slight_smile:

It should look like the sample code above.

entirely dependent on your own network.

What do you expect when you have no device?

Sorry I don’t understand that. I see in script above platform is ESP8266.
So I assume I should pick a “Generic ESP8266” for device type in wizzard below? I believe this choice is the right one, but I still prefer to ask just in case. Thank you.

choose whatever you like as long as the yaml it produces (and which you can edit if it is wrong) looks like the one posted.

The wizard just creates a basic yaml file, that’s all it does, so it doesn’t matter at all what you choose, as you are going to overwrite that with the code you paste in from the example.
You should of course choose either to just let your router set an IP for it, or set an IP that is in your range.
As this code is going to be flashed into the plug, you of course need the plug, and thus the device inside it, or it will not be able to connect to it.