Last active
December 7, 2024 17:00
-
-
Save aver-ua/496fecfded3b9fefb6e41cd2c4fec49e to your computer and use it in GitHub Desktop.
ESPHome config for Blitzwolf BW-SHP6 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
| substitutions: | |
| device_description: "Boiler connected Blitzwolf BW-SHP6 Plug" | |
| device_name: "boiler-shp-plug" | |
| sensors_update_interval: "30s" # plug sensors update interval | |
| diag_update_interval: "60s" # diagnostics sensors update interval | |
| # Higher value gives lower watt readout | |
| current_res: "0.00290" | |
| # Lower value gives lower voltage readout | |
| voltage_div: "940" | |
| # Max Power is 3450W for 15A and 2300W for 10A | |
| max_power: "2000" | |
| # 2020 model uses GPIO4 for CF1 | |
| cf1_pin: GPIO14 | |
| # BW-SHP6, outlet with powermonitoring. | |
| # One button for the relay, and one red led for the relay, as well as a blue status led | |
| # Static IP is configured, and fast_connect is enabled, as the SSID is hidden | |
| # Webserver is active and pw protected, and the OTA is password protected | |
| esphome: | |
| name: "${device_name}" | |
| comment: "${device_description}" | |
| friendly_name: Boiler SHP6 Plug | |
| on_boot: # restore relay state | |
| - priority: 600 | |
| then: | |
| - select.set_index: | |
| id: power_mode | |
| index: !lambda |- | |
| return id(restore_mode)-1; | |
| - lambda: |- | |
| switch(id(restore_mode)) | |
| { | |
| case 1:{ | |
| id(relay).turn_off(); | |
| break; | |
| } | |
| case 2:{ | |
| id(relay).turn_on(); | |
| break; | |
| } | |
| default:{ | |
| break; | |
| } | |
| } | |
| esp8266: | |
| board: esp8285 | |
| restore_from_flash: true # required on ESP8266 to enable restoring device settings upon restart | |
| preferences: | |
| flash_write_interval: 5min # set to 5min to prevent wearing out the onboard flash module too quickly | |
| # 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: "Boiler-Plug Fallback Hotspot" | |
| password: !secret ap_password | |
| captive_portal: | |
| # Sets time from Homeassistant | |
| time: | |
| - platform: homeassistant | |
| id: homeassistant_time | |
| globals: | |
| - id: restore_mode | |
| type: int | |
| restore_value: yes | |
| initial_value: "2" # 0 = Always_Off. 1 = Restore_Power_Off. 2 = Always_On. | |
| text_sensor: | |
| # Uptime Human Readable | |
| - platform: template | |
| name: Uptime HR | |
| entity_category: "diagnostic" | |
| id: uptime_human | |
| icon: mdi:clock-start | |
| - platform: wifi_info | |
| ip_address: | |
| name: "IP Address" | |
| entity_category: diagnostic | |
| mac_address: | |
| name: "Mac Address" | |
| entity_category: diagnostic | |
| # Button configuration | |
| binary_sensor: | |
| - platform: gpio | |
| name: "Button" | |
| id: plug_button | |
| pin: | |
| number: GPIO13 | |
| inverted: true | |
| on_multi_click: | |
| - timing: | |
| - ON for at most 1s | |
| - OFF for at least 0.2s | |
| then: | |
| - switch.toggle: relay | |
| - timing: | |
| - ON for at least 4s | |
| then: | |
| - button.press: Reset | |
| - platform: status | |
| name: "Status" | |
| entity_category: diagnostic | |
| # Setup of LED's used in displaying Switch status | |
| output: | |
| - platform: gpio | |
| pin: GPIO0 | |
| inverted: true | |
| id: led | |
| # Config for switch | |
| switch: | |
| - platform: gpio | |
| pin: GPIO15 | |
| restore_mode: RESTORE_DEFAULT_OFF | |
| id: relay | |
| name: "Relay" | |
| on_turn_on: | |
| - output.turn_on: led | |
| on_turn_off: | |
| - output.turn_off: led | |
| # Status LED for connection | |
| status_led: | |
| pin: | |
| number: GPIO2 | |
| inverted: true | |
| # Sensors for Voltage (V), Current (A), Power (W), Daily energy usage (kWh) | |
| sensor: | |
| - platform: hlw8012 | |
| sel_pin: | |
| number: GPIO12 | |
| inverted: true | |
| cf_pin: GPIO5 | |
| cf1_pin: ${cf1_pin} | |
| current_resistor: ${current_res} | |
| voltage_divider: ${voltage_div} | |
| current: | |
| name: "Current" | |
| unit_of_measurement: "A" | |
| accuracy_decimals: 3 | |
| icon: mdi:flash-outline | |
| voltage: | |
| name: "Voltage" | |
| unit_of_measurement: "V" | |
| icon: mdi:flash-outline | |
| power: | |
| name: "Power" | |
| unit_of_measurement: "W" | |
| id: power | |
| icon: mdi:flash-outline | |
| on_value_range: | |
| - above: ${max_power} | |
| then: | |
| - output.turn_off: led | |
| - switch.turn_off: relay | |
| energy: | |
| name: "Energy" | |
| unit_of_measurement: "Wh" | |
| icon: mdi:flash-outline | |
| change_mode_every: 4 | |
| update_interval: ${sensors_update_interval} | |
| - platform: total_daily_energy | |
| name: "Total Daily Energy" | |
| restore: true | |
| power_id: power | |
| unit_of_measurement: kWh | |
| accuracy_decimals: 3 | |
| filters: | |
| - multiply: 0.001 | |
| # Uptime sensor. | |
| - platform: uptime | |
| name: "Uptime" | |
| entity_category: "diagnostic" | |
| id: plug_uptime | |
| update_interval: ${diag_update_interval} | |
| on_raw_value: | |
| then: | |
| - text_sensor.template.publish: | |
| id: uptime_human | |
| state: !lambda |- | |
| int seconds = round(id(plug_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(); | |
| # 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: "" | |
| button: | |
| - platform: restart | |
| name: "Restart" | |
| entity_category: config | |
| - platform: factory_reset | |
| name: "Factory Reset" | |
| id: Reset | |
| entity_category: config | |
| select: | |
| - platform: template | |
| name: "Power On State" | |
| id: "power_mode" | |
| optimistic: true | |
| icon: mdi:electric-switch | |
| options: | |
| - Always Off | |
| - Always On | |
| - Restore Power Off State | |
| on_value: | |
| then: | |
| - lambda: |- | |
| id(restore_mode)=i+1; | |
| # 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