Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- substitutions:
- device_name: nousplug118
- friendly_name: "nousPlug118"
- # Higher value gives lower watt readout
- current_res: "0.00280"
- # Lower value gives lower voltage readout
- voltage_div: "775"
- esphome:
- name: ${device_name}
- platform: ESP8266
- board: esp01_1m
- wifi:
- ssid: !secret wifi_ssid
- password: !secret wifi_password
- fast_connect: true
- manual_ip:
- gateway: !secret iotgw
- subnet: !secret iotsubnet
- static_ip: !secret nousplug118
- # Enable fallback hotspot (captive portal) in case wifi connection fails
- ap:
- ssid: ${device_name} Hotspot
- password: !secret hotspot_pass
- ota:
- password: !secret ota_pass
- # Enable Home Assistant API
- api:
- captive_portal:
- # Enable Web server (optional).
- web_server:
- port: 80
- mqtt:
- broker: !secret mqtt_broker
- username: !secret mqtt_user
- password: !secret mqtt_pass
- topic_prefix: esphome
- # Enable logging
- logger:
- # Text sensors with general information.
- text_sensor:
- # Expose ESPHome version as sensor.
- - platform: version
- name: ${friendly_name} ESPHome Version
- # Expose WiFi information as sensors.
- - platform: wifi_info
- ip_address:
- name: ${friendly_name} IP
- ssid:
- name: ${friendly_name} SSID
- bssid:
- name: ${friendly_name} BSSID
- # see: https://esphome.io/components/time.html
- time:
- - platform: homeassistant
- id: homeassistant_time
- # Sensors with general information.
- sensor:
- # Uptime sensor.
- - platform: uptime
- name: ${friendly_name} Uptime
- icon: mdi:clock-outline
- # WiFi Signal sensor.
- - platform: wifi_signal
- name: ${friendly_name} WiFi Signal
- update_interval: 60s
- icon: mdi:wifi
- ###########################################
- # Device Specific Config
- - platform: total_daily_energy
- name: ${friendly_name} - Todays Usage
- power_id: "power_wattage"
- filters:
- # Multiplication factor from W to kW is 0.001
- - multiply: 0.001
- unit_of_measurement: kWh
- icon: mdi:calendar-clock
- - platform: adc
- pin: VCC
- name: ${friendly_name} - VCC Volt
- icon: mdi:flash-outline
- - platform: hlw8012
- sel_pin:
- number: GPIO12
- inverted: True
- cf_pin: GPIO05
- cf1_pin: GPIO04
- change_mode_every: 4
- current_resistor: ${current_res}
- voltage_divider: ${voltage_div}
- update_interval: 60s
- current:
- name: ${friendly_name} - Ampere
- unit_of_measurement: A
- accuracy_decimals: 3
- icon: mdi:current-ac
- voltage:
- name: ${friendly_name} - Volt
- unit_of_measurement: V
- accuracy_decimals: 1
- icon: mdi:flash-outline
- filters:
- power:
- name: ${friendly_name} - Watt
- unit_of_measurement: W
- id: "power_wattage"
- icon: mdi:gauge
- filters:
- - calibrate_linear:
- # Map 0.0 (from sensor) to 0.0 (true value)
- - 0.0 -> 0.0
- - 10.22 -> 10
- - 50.4 -> 60.0
- - 59.7 -> 70.0
- binary_sensor:
- - platform: status
- name: ${friendly_name} - Status
- device_class: connectivity
- # toggle relay on/off
- - platform: gpio
- pin:
- number: GPIO13
- mode: INPUT_PULLUP
- inverted: True
- id: ${device_name}_button_state
- on_press:
- - switch.toggle: button_switch
- status_led:
- pin:
- number: GPIO02
- inverted: true
- id: led_blue
- output:
- - platform: gpio
- pin: GPIO00
- inverted: true
- id: led_red
- switch:
- - platform: template
- name: ${friendly_name} - Switch
- icon: mdi:power
- optimistic: true
- restore_state: true
- id: button_switch
- on_turn_on:
- - switch.turn_on: relay
- - output.turn_off: led_red
- on_turn_off:
- - switch.turn_off: relay
- - output.turn_on: led_red
- - platform: gpio
- pin: GPIO15
- id: relay
- restore_mode: ALWAYS_ON
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement