Last active
December 7, 2024 09:40
-
-
Save aver-ua/b4372bb2775ea13435beb4142a0038f5 to your computer and use it in GitHub Desktop.
ESPHome config for Beken bk72xx Smart Plug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| esphome: | |
| name: freezer-plug | |
| comment: "${device_description}" | |
| friendly_name: Freezer Plug | |
| substitutions: | |
| device_description: "Freezer Plug with power metering" | |
| power_update_interval: 15s | |
| diag_update_interval: 60s | |
| max_power: "2000" | |
| time: | |
| - platform: homeassistant | |
| id: homeassistant_time | |
| bk72xx: | |
| board: generic-bk7231t-qfn32-tuya | |
| # Enable logging | |
| logger: | |
| # Enable Home Assistant API | |
| api: | |
| encryption: | |
| key: !secret api_encryption_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: "Freezer-Plug Fallback Hotspot" | |
| password: !secret ap_password | |
| captive_portal: | |
| button: | |
| - platform: restart | |
| name: Restart | |
| debug: | |
| update_interval: 30s | |
| text_sensor: | |
| - platform: debug | |
| reset_reason: | |
| name: Reset Reason | |
| - platform: libretiny | |
| version: | |
| name: LibreTiny Version | |
| # Uptime Human Readable | |
| - platform: template | |
| name: Uptime HR | |
| id: uptime_human | |
| icon: mdi:clock-start | |
| sensor: | |
| - platform: uptime | |
| name: Uptime | |
| id: esp_uptime | |
| update_interval: ${diag_update_interval} | |
| on_raw_value: | |
| then: | |
| - text_sensor.template.publish: | |
| id: uptime_human | |
| state: !lambda |- | |
| int seconds = round(id(esp_uptime).raw_state); | |
| int days = seconds / (24 * 3600); | |
| seconds = seconds % (24 * 3600); | |
| int hours = seconds / 3600; | |
| seconds = seconds % 3600; | |
| int minutes = seconds / 60; | |
| seconds = seconds % 60; | |
| return ( | |
| (days ? String(days) + "d " : "") + | |
| (hours ? String(hours) + "h " : "") + | |
| (minutes ? String(minutes) + "m " : "") + | |
| (String(seconds) + "s") | |
| ).c_str(); | |
| - platform: hlw8012 | |
| model: BL0937 | |
| cf_pin: | |
| number: P7 | |
| inverted: true | |
| cf1_pin: | |
| number: P8 | |
| inverted: true | |
| sel_pin: | |
| number: P24 | |
| inverted: true | |
| current: | |
| name: BL0937 Current | |
| filters: | |
| - multiply: 0.5 | |
| voltage: | |
| name: BL0937 Voltage | |
| power: | |
| name: BL0937 Power | |
| id: power_sensor | |
| on_value_range: | |
| - above: ${max_power} | |
| then: | |
| - switch.turn_off: switch_1 | |
| energy: | |
| name: BL0937 Energy | |
| voltage_divider: 863 #845 | |
| current_resistor: 0.001 ohm | |
| update_interval: ${power_update_interval} | |
| #change_mode_every: 1 | |
| # WiFi Signal sensor. | |
| - platform: wifi_signal | |
| name: "WiFi Signal dB" | |
| id: wifi_signal_db | |
| entity_category: "diagnostic" | |
| update_interval: ${diag_update_interval} | |
| - platform: copy # Reports the WiFi signal strength in % | |
| source_id: wifi_signal_db | |
| name: "WiFi Signal Percent" | |
| filters: | |
| - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0); | |
| unit_of_measurement: "%" | |
| entity_category: "diagnostic" | |
| device_class: "" | |
| - platform: total_daily_energy | |
| name: "Total Daily Energy" | |
| restore: true | |
| power_id: power_sensor | |
| unit_of_measurement: kWh | |
| accuracy_decimals: 3 | |
| filters: | |
| - multiply: 0.001 | |
| binary_sensor: | |
| - platform: gpio | |
| id: binary_switch_1 | |
| pin: | |
| number: P10 | |
| inverted: true | |
| mode: INPUT_PULLUP | |
| on_press: | |
| then: | |
| - switch.toggle: switch_1 | |
| switch: | |
| - platform: gpio | |
| id: switch_1 | |
| name: Relay 1 | |
| pin: P26 | |
| restore_mode: RESTORE_DEFAULT_ON | |
| status_led: | |
| pin: | |
| number: P6 | |
| inverted: true | |
| # Enable Web server. | |
| web_server: | |
| port: 80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment