I’ve gotten a few BW-SHP7 (double socket smart switch) and a BW-SHP9 (tripple socket smart switch).
I’ve gone through the migration from Tasmota to ESPHome, and I got the relays working, and on the SHP7 the powermonitoring is working as well.
But on neither of them I can get the buttons to work. The relays works fine through HomeAssistant.
On SHP7 there are two buttons, one for each socket.
On SHP9 there are only one button, for the four relays (3 sockets and one double USB output).
The SHP9 looks like this in tasmota:
The code for the SHP9 looks like this so far, I’ve tried both with on_press, on_click, on_double_click and multiclick, but so far without luck.
substitutions:
device_name: livingroomextension
# NO Powermeasurement
# BW-SHP9
esphome:
name: '${device_name}'
platform: ESP8266
board: esp8285
on_boot:
then:
- switch.turn_on: relay1
- switch.turn_on: relay2
# - switch.turn_on: relay3
- switch.turn_on: relay4
wifi:
ssid: !secret wifissid
password: !secret wifipw
# reboot_timeout: 60min
manual_ip:
static_ip: 10.11.13.44
gateway: 10.11.13.1
subnet: 255.255.255.0
# use_address: 10.11.12.201
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
name: button1
id: button1
pin:
number: GPIO13
on_click:
min_length: 50ms
max_length: 350ms
then:
- switch.toggle: relay1
- platform: gpio
name: button2
id: button2
pin:
number: GPIO13
on_double_click:
min_length: 50ms
max_length: 350ms
then:
- switch.turn_off: relay2
# - timing:
# - ON for at most 1s
# - OFF for at most 1s
# - ON for at most 1s
# - OFF for at least 0.2s
# then:
# - switch.toggle: relay2
# - timing:
# - ON for 1s to 2s
# - OFF for at least 0.5s
# then:
# - switch.toggle: relay4
# - timing:
# - ON for at most 1s
# - OFF for at least 0.5s
# then:
# - switch.toggle: relay1
switch:
- platform: gpio
pin: GPIO12
id: relay1
name: 'socket1'
- platform: gpio
pin: GPIO14
id: relay2
name: 'socket2'
- platform: gpio
pin: GPIO5
id: relay3
name: 'socket3'
- platform: gpio
pin: GPIO15
id: relay4
name: 'usb-socket'
status_led:
pin:
number: GPIO0
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
My SHP7 looks like this:
substitutions:
device_name: serverroompower
# Higher value gives lower watt readout
current_res: '0.002291'
# Lower value gives lower voltage readout
voltage_div: '940'
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: 10.11.13.43
gateway: 10.11.13.1
subnet: 255.255.255.0
# use_address: 10.11.12.201
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
on_press:
- switch.toggle: relay1
- platform: gpio
id: button2
name: button2
internal: true
pin:
number: GPIO15
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
# - platform: gpio
# pin: GPIO13
# inverted: true
# id: led1
# - platform: gpio
# pin: GPIO02
# inverted: true
# id: led2
switch:
- platform: gpio
pin: GPIO14
id: relay1
name: 'server'
on_turn_on:
- output.turn_on: led1
on_turn_off:
- output.turn_off: led1
- platform: gpio
pin: GPIO16
id: relay2
name: 'freezerlight'
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: 5
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
On the SHP7 the LED’s work, powermonitoring, relays, but still no buttons.
Any help out there?