Esphome and Blitzwolf SHP5?

Anyone using Esphome on Blitzwolf SHP5 who could share the config?

1 Like

You can usually figure it out from the tasmota configuration

Which is a bit mysterious until you read the template explanation here

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

it looks good, i have made almost the same config. Except i see in your config that the usp relay uses the same GPIO14 as the main Relay in my opinion it needs to be GPIO5.
I just give it a try on my BW-SHP5 but it gets in a bootloop.
I hear the click of the Relay and it does not come back online (from a blank ESPhome config)

Thanks, I updated the config above. Sounds like you need to do some soldering.

I have running Tasmota on it without any problems so i guess there is no soldering needed.

Hi,
Thantk you for your config!
I’m trying to use it with Gosund SP112 (which is twin to SHP5, afaik), but not everything seems to work fine. Power measurments are strange (even that nothing is connected to switch it shows 1,5W of use, voltage is almost twice lower than it suppose to be, got no state for usb raley switch, no wifi/ip/button/ssid readings). How can I fix this?

Thanks for the config, it seems to work nice for me too! I have two questions though;

  1. Should the voltage not be reading ~230V for me as I live in Europe?
  2. Is there any way to use the blue LED light in the powerbutton?

The measurement values needs to be calibrated to get correct values. Frenck.dev has a guide you can follow. But if you only intend to check if the connected TV, boiler etc is on or off, the calibration is not needed. Just use the values you get. Calibration Will only scale the values up or down.

Regarding USB switch, if you can toggle it you might need to put it in optimistic mode.

Tried the sketch made by depen but my unit also got into a boot loop and I had to do some soldering to reflash the unit.

Is there a complete and working ESPhome sketch for the SHP5 unit or am I doing something wrong with the sketch resolving in a loop boot?

Regards.

I’m sorry to hear that. It might be GPIO00 causing the boot loop. Either remove the inverted true or change temporarily to a unused GPIO (GPIO10 etc).

Both not working, I changed GPIO00 to GPIO10 and commented out the inverted line. Need to reflash the unit using wires.

Any idea what else could be the problem here?

Ok, I have one more idea. Uart and logger conflict. Set

logger:
  baud_rate: 0

That was the issue indeed. I did not find the time to calibrate the unit and test if everything is working but it does not have a reboot loop anymore…

Thnx

I just bought a SHP5, so just to be sure @bramschats you used the ESPHome config from @depen as given here? And everything is working fine? :slight_smile:

Yes, that should work. I did not find time to calibrate the device yet and it displays 110volts but the sketch works fine! When you have a proper calibration/ configuration, please let me know.

1 Like

When I upload the compiled esphome bin file to the SPH5 ( it has Tasmota running ), it says it can’t upgrade because it’s not compatible.

Migrating from Tasmoto like mentioned here https://esphome.io/guides/migrate_sonoff_tasmota.html should work right?

Ha found work around: https://github.com/esphome/issues/issues/955#issuecomment-571004252

Anyone able to calibrate the device yet?

hey @bramschats I tried following the linear calibration as pointed out on Frenck his blog. But not able to get it fine tuned somehow…
Anyone care to show his approach with screenshots or youtube movie?

1 Like