Skip to content

Instantly share code, notes, and snippets.

@ungeskriptet
Last active July 21, 2024 17:24
Show Gist options
  • Save ungeskriptet/da70cf12e058aee58c589f77fe1b5b35 to your computer and use it in GitHub Desktop.
Save ungeskriptet/da70cf12e058aee58c589f77fe1b5b35 to your computer and use it in GitHub Desktop.
ESPHome YAML configs
esphome:
name: bk7231n-plug-9229
friendly_name: bk7231n-plug-9229
bk72xx:
board: cb2s
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: !secret api_key
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "bk7231n-plug-9229 Hotspot"
password: !secret hotspot_password
captive_portal:
switch:
- platform: gpio
id: relay
name: Relay
pin: P26
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
- switch.turn_on: statusled
on_turn_off:
- switch.turn_off: statusled
- platform: gpio
id: statusled
pin: P8
inverted: true
restore_mode: RESTORE_DEFAULT_OFF
binary_sensor:
- platform: gpio
device_class: power
pin:
number: P10
mode: INPUT_PULLUP
inverted: True
name: Button
internal: True
on_press:
- switch.toggle: statusled
- switch.toggle: relay
esphome:
name: bk7231n-plug-b69a
friendly_name: bk7231n-plug-b69a
bk72xx:
board: cb2s
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: !secret api_key
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "bk7231n-plug-b69a Hotspot"
password: !secret hotspot_password
captive_portal:
switch:
- platform: gpio
id: relay
name: Relay
pin: P26
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
- switch.turn_on: statusled
on_turn_off:
- switch.turn_off: statusled
- platform: gpio
id: statusled
pin: P8
inverted: true
restore_mode: RESTORE_DEFAULT_OFF
internal: True
binary_sensor:
- platform: gpio
device_class: power
pin:
number: P23
mode: INPUT_PULLUP
name: Button
internal: True
on_press:
- switch.toggle: statusled
- switch.toggle: relay
time:
- platform: homeassistant
id: homeassistant_time
sensor:
- platform: hlw8012
model: BL0937
sel_pin: P24
cf_pin: P7
cf1_pin: P6
current:
name: "Current"
voltage:
name: "Voltage"
power:
name: "Power"
id: power
update_interval: 1s
initial_mode: CURRENT
change_mode_every: 8
current_resistor: 0.001
voltage_divider: 1600
# Reports the total Power so-far each day, resets at midnight, see https://esphome.io/components/sensor/total_daily_energy.html
- platform: total_daily_energy
name: Total Daily Energy
icon: mdi:circle-slice-3
power_id: power
filters:
- multiply: 0.001
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
substitutions:
current_res: "0.001" # Power monitoring calibration https://esphome.io/components/sensor/hlw8012.html
voltage_div: "1600" # Power monitoring calibration
esphome:
name: rtl8710bx-plug-4f5d
friendly_name: rtl8710bx-plug-4f5d
rtl87xx:
board: wr2
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: !secret api_key
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "rtl8710bx-plug-4f5d Hotspot"
password: !secret hotspot_password
captive_portal:
time:
- platform: homeassistant
id: homeassistant_time
binary_sensor:
# Button on the front is pressed and then toggle relay
- platform: gpio
device_class: power
pin:
number: PA18
mode: INPUT_PULLUP
inverted: True
name: Button
internal: True
on_press:
- switch.toggle: relay
- switch.toggle: statusled
switch:
# Relay itself
- platform: gpio
name: Relay
pin: PA15
id: relay
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
name: statusled
pin: PA05
id: statusled
restore_mode: RESTORE_DEFAULT_OFF
inverted: true
internal: True
sensor:
- platform: hlw8012
model: BL0937
sel_pin:
number: PA14
inverted: true
cf_pin: PA00
cf1_pin: PA12
current:
name: "Current"
voltage:
name: "Voltage"
power:
name: "Power"
id: power
update_interval: 1s
initial_mode: CURRENT
change_mode_every: 8
current_resistor: ${current_res}
voltage_divider: ${voltage_div}
# Reports the total Power so-far each day, resets at midnight, see https://esphome.io/components/sensor/total_daily_energy.html
- platform: total_daily_energy
name: Total Daily Energy
icon: mdi:circle-slice-3
power_id: power
filters:
- multiply: 0.001
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
esphome:
name: t34-switch-864b
friendly_name: t34-switch-864b
bk72xx:
board: generic-bk7231n-qfn32-tuya
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: !secret api_key
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "t34-switch-864b Hotspot"
password: !secret hotspot_password
captive_portal:
switch:
- platform: gpio
id: relay
name: Relay
pin: P15
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
id: statusled
pin: P6
inverted: true
restore_mode: RESTORE_DEFAULT_OFF
binary_sensor:
# Button on the front is pressed and then toggle relay
- platform: gpio
device_class: light
pin:
number: P24
mode: INPUT_PULLUP
inverted: True
name: Button
internal: True
on_press:
- switch.toggle: relay
- platform: gpio
device_class: light
pin:
number: P14
mode: INPUT_PULLUP
inverted: True
name: Lights
internal: True
on_state:
- switch.toggle: relay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment