substitutions:devicename:brilliant_smartplug_1friendly_name:Brilliant Smartplug 1device_description:Brilliant Lighting BL20925 Power Monitoring Plug with button and Blue led.esphome:name:$devicenamecomment:${device_description}platform:ESP8266wifi:ssid:!secretwifi_ssidpassword:!secretwifi_password# Enable fallback hotspot (captive portal) in case wifi connection failsap:ssid:"BrilliantPlug1"password:!secretAP_Passwordmanual_ip:static_ip:192.168.x.xxgateway:192.168.x.xsubnet:255.255.255.0captive_portal:# Enable logginglogger:# Web server can be removed after enabling HA API#web_server:# port: 80# Enable Home Assistant APIapi:password:!secretOTA_Passwordota:password:!secretOTA_Password# Enable time component for use by daily power sensortime:-platform:homeassistantid:homeassistant_timesensor:# Reports how long the device has been powered (in minutes)-platform:uptimename:${friendly_name} Uptimefilters:-lambda:return x / 60.0;unit_of_measurement:minutes# Reports the WiFi signal strength-platform:wifi_signalname:${friendly_name} Wifi Signalupdate_interval:60s# Reports the Current, Voltage, and Power used by the plugged-in device-platform:hlw8012sel_pin:number:GPIO12inverted:truecf_pin:GPIO04cf1_pin:GPIO05change_mode_every:3update_interval:3spower:name:${friendly_name} Powerunit_of_measurement:Wid:wattagecurrent:name:${friendly_name} Currentunit_of_measurement:Avoltage:name:${friendly_name} Voltageunit_of_measurement:V# Reports the total Power so-far each day, resets at midnight, see https://esphome.io/components/sensor/total_daily_energy.html-platform:total_daily_energyname:${friendly_name} Total Daily Energypower_id:wattagefilters:-multiply:0.001unit_of_measurement:kWhbinary_sensor:# Button on the front is pressed and then toggle relay-platform:gpiodevice_class:powerpin:number:GPIO03inverted:Truename:${friendly_name} Button# Name to make button visible in HAon_press:-switch.toggle:relaytext_sensor:# Reports the ESPHome Version with compile date-platform:versionname:${friendly_name} ESPHome Version# Reports detailed wifi info, can be commented out-platform:wifi_infoip_address:name:${friendly_name} IP Address# ssid: # Some additional wifi info that is not normally needed# name: ${friendly_name} Connected SSID# bssid:# name: ${friendly_name} Connected BSSIDswitch:# Relay itself-platform:gpioname:${friendly_name}pin:GPIO14id:relayrestore_mode:RESTORE_DEFAULT_OFF#Try to restore relay state after reboot/power-loss event.#RESTORE_DEFAULT_OFF (Default) - Attempt to restore state and default to OFF if not possible to restore. Uses flash write cycles.#RESTORE_DEFAULT_ON - Attempt to restore state and default to ON. Uses flash write cycles.#ALWAYS_OFF - Always initialize the pin as OFF on bootup. Does not use flash write cycles.#ALWAYS_ON - Always initialize the pin as ON on bootup. Does not use flash write cycles.on_turn_on:# Action when relay is turned on-script.execute:led_power_onon_turn_off:# Action when relay is turned off-script.execute:led_relay_offoutput:# Output GPIOs for blue led-platform:esp8266_pwm# Blueid:brilliant_smartplug_1_blue_outputpin:number:GPIO013inverted:Truelight:# RGB light-platform:monochromaticname:${friendly_name} Lightoutput:brilliant_smartplug_1_blue_outputid:brilliant_smartplug_1_blue_led# Blink the blue light if we aren't connected to WiFi. Could use https://esphome.io/components/status_led.html instead but then we couldn't use the blue light for other things as well.# Only if not connected after 30sinterval:-interval:2000msthen:-if:condition:for:time:30scondition:not:wifi.connected:then:-light.turn_on:id:brilliant_smartplug_1_blue_ledbrightness:100%script:-id:led_relay_off# Normal operation when relay is offthen:-light.turn_off:id:brilliant_smartplug_1_blue_led-id:led_power_on# Normal operation when relay is onthen:-light.turn_on:id:brilliant_smartplug_1_blue_ledbrightness:80%