Skip to content

Instantly share code, notes, and snippets.

@nicolasvila
Last active September 19, 2023 22:48
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolasvila/ce8b842ba6326caecb719fba87fee0b0 to your computer and use it in GitHub Desktop.
Save nicolasvila/ce8b842ba6326caecb719fba87fee0b0 to your computer and use it in GitHub Desktop.
NEO Coolcam NAS-WR01W 16A Smart Wifi Plug (ESPHome script)
esphome:
name: wifi-plug-01 #<--- CHANGE ME !
platform: ESP8266
board: esp8285
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "fe4e2f8232d3b1846534da15b5b9a4b1" #<--- CHANGE ME !
wifi:
ssid: "my_wifi" #<--- CHANGE ME !
password: "my_wifi_password" #<--- CHANGE ME !
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "wifi-plug-01 Fallback Hotspot" #<--- CHANGE ME !
password: "GXBBGxBKMNXk" #<--- CHANGE ME !
captive_portal:
substitutions:
plug_name: coolcam_plug1
# Higher value gives lower watt readout
current_res: "0.00221"
# Lower value gives lower voltage readout
voltage_div: "800"
binary_sensor:
- platform: gpio
pin:
number: GPIO0
inverted: true
name: "${plug_name}_button"
on_press:
- switch.toggle: relay
switch:
- platform: gpio
name: "${plug_name}_LED_Red"
pin: GPIO13
inverted: true
restore_mode: ALWAYS_OFF
id: red_led
- platform: gpio
name: "${plug_name}_Relay"
pin: GPIO14
restore_mode: ALWAYS_ON
id: relay
on_turn_on:
- switch.turn_on: red_led
on_turn_off:
- switch.turn_off: red_led
sensor:
- platform: hlw8012
sel_pin:
number: GPIO12
inverted: true
cf_pin: GPIO04
cf1_pin: GPIO05
current_resistor: ${current_res}
voltage_divider: ${voltage_div}
current:
name: "${plug_name}_Amperage"
unit_of_measurement: A
voltage:
name: "${plug_name}_Voltage"
unit_of_measurement: V
power:
name: "${plug_name}_Wattage"
unit_of_measurement: W
id: "${plug_name}_Wattage"
change_mode_every: 8
update_interval: 10s
- platform: total_daily_energy
name: "${plug_name}_Total Daily Energy"
power_id: "${plug_name}_Wattage"
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
unit_of_measurement: kWh
# Extra sensor to keep track of plug uptime
- platform: uptime
name: ${plug_name}_Uptime SensorPreformatted text
# Example configuration entry
time:
- platform: homeassistant
id: homeassistant_time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment