Skip to content

Instantly share code, notes, and snippets.

@christhehoff
Created July 11, 2020 05:44
Show Gist options
  • Save christhehoff/342423a4ee769458461be0a24cdbe4e8 to your computer and use it in GitHub Desktop.
Save christhehoff/342423a4ee769458461be0a24cdbe4e8 to your computer and use it in GitHub Desktop.
ESPHome based power meter for EM5100 "smart" meters
esphome:
name: esphome_power_meter
platform: ESP8266
board: nodemcuv2
wifi:
ssid: SSID
password: PASSWORD
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome Power Meter"
password: "SDAFLKHJ@#(*R&ASDFLHJK"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
password: "secret"
ota:
password: "secret"
sensor:
# This is the LDR Light sensor on the "wH" port - this flashses for both IMPORT and EXPORT
- platform: pulse_counter
name: 'Import Export Power Meter'
id: 'impexp_power'
pin: GPIO5
unit_of_measurement: 'kW'
filters:
# Convert pulses per minutes into kW
- multiply: 0.06
update_interval: 30s
# This is the IR sensor on the "TEST" port - flahses for power IMPORT only
- platform: pulse_counter
name: 'Import Power Meter'
id: 'import_power'
pin: GPIO4
unit_of_measurement: 'kW'
filters:
# Convert pulses per minutes into kW
- multiply: 0.06
update_interval: 30s
# Derived sensor for EXPORT (=Total - IMPORT)
- platform: template
name: 'Export Power Meter'
id: 'export_power'
icon: mdi:pulse
unit_of_measurement: 'kW'
lambda: !lambda |-
if (id(import_power).state > id(impexp_power).state) {
return 0.0;
} else {
return id(impexp_power).state - id(import_power).state;
}
update_interval: 30s
# Now for the daily totals
- platform: total_daily_energy
name: "Total Daily Import Energy"
power_id: import_power
icon: mdi:transmission-tower
accuracy_decimals: 2
- platform: total_daily_energy
name: "Total Daily Export Energy"
power_id: export_power
icon: mdi:solar-power
accuracy_decimals: 2
# Report on signal strength - useful for when its outside in a faraday cage
- platform: wifi_signal
name: "Power Meter WiFi Signal Sensor"
update_interval: 60s
- platform: adc
pin: VCC
name: “Power Meter Battery Voltage”
update_interval: 60s
time:
- platform: homeassistant
id: homeassistant_time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment