Projekte & Automatisierung

Howto Smartplug

der Modelle: Gosund SP1 / BlitzWolf® BW-SHP2 / Teckin 21 & 22

Weitere Informationen folgen.

ESPHome yaml

esphome:
  # abcdefghijklmnopqrstuvwxyz0123456789_
  name: gosund_1
  platform: ESP8266
  board: esp8285

# WiFi connection
wifi:
  networks:
  - ssid: 'SSID WIFI 1'
    password: 'PASSWORD WIFI 1'
  - ssid: 'PASSWORD WIFI 2'
    password: 'PASSWORD WIFI 2'

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: 'password'

# Enable over-the-air updates
ota:
  password: 'password'

# Enable Web server
web_server:
  port: 80

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

# Text sensors with general information
text_sensor:
  - platform: version
    name: Version
  - platform: wifi_info
    ip_address:
      name: IP
    ssid:
      name: SSID
    bssid:
      name: BSSID

sensor:
  # Uptime sensor
  - platform: uptime
    name: Uptime
  # WiFi Signal sensor
  - platform: wifi_signal
    name: WIFI_Signal
    update_interval: 10s
  # Power sensor
  - platform: hlw8012
    sel_pin:
      number: GPIO12
      inverted: true
    cf_pin: GPIO04
    cf1_pin: GPIO05
    change_mode_every: 3
    update_interval: 3s
    # Current sensor
    current:
      name: Current
      unit_of_measurement: A
      accuracy_decimals: 3
      filters:
        # Map from sensor -> measured value
        ##### WERTE MESSEN & EINTRAGEN #####
        ##### Dienen zur Demonstration #####
        - calibrate_linear:
            - 0.0 -> 0.012
            - 0.07725 -> 0.063
            - 1.14910 -> 0.881
            - 3.37489 -> 2.588
            - 4.45157 -> 3.400
            - 6.19453 -> 4.750
            - 7.80231 -> 5.980
        # 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: Voltage
      unit_of_measurement: V
      accuracy_decimals: 1
      filters:
        # Map from sensor -> measured value
        ##### WERTE MESSEN & EINTRAGEN #####
        ##### Dienen zur Demonstration #####
        - calibrate_linear:
            - 0.0 -> 0.0
            - 579.03796 -> 218
            - 584.62262 -> 220
            - 588.02789 -> 221
            - 585.84851 -> 222
            - 591.16077 -> 223
    # Power sensor
    power:
      id: power
      name: Power
      unit_of_measurement: W
      accuracy_decimals: 0
      filters:
        # Map from sensor -> measured value
        ##### WERTE MESSEN & EINTRAGEN #####
        ##### Dienen zur Demonstration #####
        - calibrate_linear:
            - 0.0 -> 1.13
            - 62.06167 -> 11.02
            - 234.45520 -> 38.5
            - 1092.97498 -> 177
            - 2120.44043 -> 343
            - 2844.49341 -> 460
            - 4651.17725 -> 755
            - 5571.75928 -> 900
            - 6250.98926 -> 1006
            - 8526.58398 -> 1365
        # 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: 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: Button
    pin:
      number: GPIO3
      inverted: true
    on_press:
      - switch.toggle: relay

switch:
  # Switch to restart the plug
  - platform: restart
    name: Restart
  # Switch to toggle the relay
  - platform: gpio
    id: relay
    name: Switch
    pin: GPIO14
    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: GPIO1
      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: GPIO13
    inverted: true