-
-
Save ChristianRonningen/ee6ec5941bb2212473c793b548d7d47d to your computer and use it in GitHub Desktop.
ESPHome Configuration for Nedis WIFIP121FWT
This file contains 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: nedis-esp-004 | |
on_boot: | |
priority: -100 | |
then: | |
- light.turn_on: ${device_name}_light_blue_status | |
substitutions: | |
device_name: nedis_esp_004 | |
friendly_name: Nedis ESP 004 | |
# Nedis WIFIP121FWT with bk7231N | |
# Generate correct API-key after copy-paste | |
# Create HA input Helper (example 0-7200 seconds) with device friendly_name. | |
# Use Cloud Cutter profile: tuya-generic-fs-02we-1ch-16a-smart-switch-with-energy-monitoring | |
# DISCLAIMER: The Rear Lights Warranty is on. Use at your own risk! | |
bk72xx: | |
board: generic-bk7231n-qfn32-tuya | |
logger: | |
web_server: | |
captive_portal: | |
ota: | |
password: !secret ota_password | |
mdns: | |
api: | |
encryption: | |
key: "Generate API-key: https://esphome.io/components/api.html?highlight=randomly%20generated" | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_password | |
ap: | |
ssid: "${friendly_name} Fallback Hotspot" | |
password: !secret ap_password | |
text_sensor: | |
- platform: libretiny | |
version: | |
name: ${device_name} LibreTiny Version | |
binary_sensor: | |
- platform: gpio | |
id: ${device_name}_binary_switch_1 | |
pin: | |
number: P7 | |
inverted: false | |
mode: INPUT_PULLUP | |
on_press: | |
then: | |
- switch.toggle: ${device_name}_switch_1 | |
switch: | |
- platform: gpio | |
id: ${device_name}_switch_1 | |
name: ${friendly_name} Relay 1 | |
pin: P8 | |
on_turn_on: | |
- light.turn_on: ${device_name}_red_light_status | |
- script.execute: pulsetime # Initialize pulsetime script | |
on_turn_off: | |
- light.turn_off: ${device_name}_red_light_status | |
- script.stop: pulsetime # Initialize pulsetime script | |
light: | |
- platform: status_led | |
id: ${device_name}_blue_light_status | |
pin: | |
number: P10 | |
inverted: false | |
- platform: status_led | |
id: ${device_name}_red_light_status | |
pin: | |
number: P6 | |
inverted: false | |
sensor: | |
- platform: hlw8012 | |
model: BL0937 | |
cf_pin: | |
number: P26 | |
inverted: true | |
cf1_pin: | |
number: P24 | |
inverted: true | |
sel_pin: | |
number: P11 | |
inverted: true | |
current: | |
name: ${friendly_name} Current | |
id: ${device_name}_current | |
voltage: | |
name: ${friendly_name} Voltage | |
id: ${device_name}_voltage | |
filters: | |
# Map from sensor -> measured value | |
- calibrate_linear: | |
- 0.0 -> 0.0 | |
- 569.8 -> 234 | |
power: | |
name: ${friendly_name} Power | |
id: ${device_name}_power | |
energy: | |
name: ${friendly_name} Energy | |
id: ${device_name}_energy | |
voltage_divider: 1881 # 4 * 470K resistors upstream and 1k resistor downstream for voltage divider (4 x 470 000 + 1000) / 1000 | |
current_resistor: 0.001 ohm | |
update_interval: 60s | |
# Example configuration entry with 2 sensors and filter | |
- platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB | |
name: "${friendly_name} WiFi Signal dB" | |
id: ${device_name}_wifi_signal_db | |
update_interval: 60s | |
entity_category: "diagnostic" | |
- platform: copy # Reports the WiFi signal strength in % | |
source_id: ${device_name}_wifi_signal_db | |
name: "${friendly_name} WiFi Signal Percent" | |
filters: | |
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0); | |
unit_of_measurement: "%" | |
entity_category: "diagnostic" | |
# Input helper as sensor for pulsetime script | |
- platform: homeassistant | |
name: "${friendly_name} Pulsetime" | |
id: ${device_name}_pulsetime | |
entity_id: input_number.${device_name}_pulsetime #The entity of input_number in HA | |
# Tasmota like pulsetime script | |
script: | |
- id: pulsetime | |
then: | |
- if: | |
condition: | |
lambda: 'return id(${device_name}_pulsetime).state > 0;' # Disable pulsetime if Helper is set to 0 | |
then: | |
- delay: !lambda |- | |
return id(${device_name}_pulsetime).state * 1000; | |
- switch.turn_off: ${device_name}_switch_1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://esphome.io/components/sensor/hlw8012.html#hlw8012-power-sensor