Last active
May 8, 2024 16:23
-
-
Save boozeman/571e0efc94938724b691577b8353f080 to your computer and use it in GitHub Desktop.
ESPHome configuration for Nedis WIFIPO120FWT
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-003 | |
substitutions: | |
device_name: nedis_esp_003 | |
friendly_name: Nedis ESP 003 | |
# Nedis WIFIPO120FWT with bk7231N chip has markings "10T40 and µ" on it's label | |
# Nedis WIFIPO120FWT with bk7231T chip has no those markings on it's label (BL0937 pins CF=P7, CF1=P8 and sel=P24, Light=P6 other pins the same) | |
# Use Cloud Cutter profile: tuya-generic-fs-02we-1ch-16a-smart-switch-with-energy-monitoring | |
# Generate correct API-key after copy-paste | |
# Create HA input Helper (example 0-7200 seconds) with device friendly_name for pulsetime Function | |
# 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: P10 | |
inverted: true | |
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: P26 | |
on_turn_on: | |
- light.turn_on: ${device_name}_light_status | |
- script.execute: pulsetime # Initialize pulsetime script | |
on_turn_off: | |
- light.turn_off: ${device_name}_light_status | |
- script.stop: pulsetime # Initialize pulsetime script | |
light: | |
- platform: status_led | |
id: ${device_name}_light_status | |
pin: | |
number: P8 | |
inverted: true | |
sensor: | |
- platform: hlw8012 | |
model: BL0937 | |
cf_pin: | |
number: P7 | |
inverted: true | |
cf1_pin: | |
number: P6 | |
inverted: true | |
sel_pin: | |
number: P24 | |
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 Check values for your own plug! | |
- calibrate_linear: | |
- 0.0 -> 0.0 | |
- 604.8 -> 236 | |
power: | |
name: ${friendly_name} Power | |
id: ${device_name}_power | |
filters: | |
# Map from sensor -> measured value Check values for your own plug! | |
- calibrate_linear: | |
- 0.0 -> 0.0 | |
- 720.7 -> 266.8 | |
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
Thank you..
I got everything working now. I managed to calibrate the HLW8012 Power Sensor as well, but I used guide on the ESPHome site for that.
Its a bit different from how you did it in your code here, I am not sure if its any right or wrong.
I used another powerplug and a 1000w heater when adjusting it, and they seem to show pretty much the same values now.
Here is my entire code now, could you see if I messed up something.
Another thing.. I have no idea what this does:
I dont see anything in Home Assistant from it either.