Hi there, I am seeing some weird readings on my HomeAssistant Glow
Normally it’s sitting at around 30KW and every couple of seconds it drops to 4K and then back to 30K
I’m hoping someone else has had something like that and fixed it any pointers would be great.
The code I have put on the ESP32
---
# Home Assistant Glow
#
# Read your electricity meter by means of the pulse LED on your
# meter, useful if you do not have a serial port (P1).
#
substitutions:
slug: electricity-monitor
name: Electricity Monitor
description: "Measure your energy consumption with the pulse LED on your smart meter"
time_timezone: "Africa/Johannesburg"
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
wifi_ap_password: "esphome-${slug}"
pulse_pin: GPIO12
status_led: GPIO5
# imp/kWh rate ⬇ #
pulse_rate: '1000'
api:
id: component_api
reboot_timeout: 30min
services:
- service: reset_total_energy
then:
- button.press:
id: button_reset_total
captive_portal: ~
logger:
id: component_logger
baud_rate: 0
ota:
id: component_ota
safe_mode: true
reboot_timeout: 10min
num_attempts: 5
button:
- platform: restart
id: switch_restart
name: "${name} Restart"
- platform: template
name: "Reset - Total Energy"
id: button_reset_total
on_press:
- pulse_meter.set_total_pulses:
id: sensor_energy_pulse_meter
value: 0
time:
- platform: homeassistant
id: time_homeassistant
timezone: "${time_timezone}"
on_time_sync:
- component.update: sensor_uptime_timestamp
- platform: sntp
id: time_sntp
servers:
- !secret ntp_server
timezone: "${time_timezone}"
sensor:
- platform: uptime
id: sensor_uptime
- platform: template
id: sensor_uptime_timestamp
name: "${name} Uptime"
device_class: "timestamp"
accuracy_decimals: 0
update_interval: never
lambda: |-
static float timestamp = (
id(time_homeassistant).utcnow().timestamp - id(sensor_uptime).state
);
return timestamp;
- platform: template
id: sensor_wifi_signal_percentage
name: "${name} Wi-Fi Signal Percentage"
icon: "mdi:wifi"
unit_of_measurement: "%"
update_interval: never
lambda: |-
if (id(sensor_wifi_signal).state) {
if (id(sensor_wifi_signal).state <= -100 ) {
return 0;
} else if (id(sensor_wifi_signal).state >= -50) {
return 100;
} else {
return 2 * (id(sensor_wifi_signal).state + 100);
}
} else {
return NAN;
}
- platform: wifi_signal
id: sensor_wifi_signal
name: "${name} Wi-Fi Signal"
update_interval: 300s
on_value:
- component.update: sensor_wifi_signal_percentage
# Pulse meter
- platform: pulse_meter
name: '${name} - Power Consumption'
id: sensor_energy_pulse_meter
unit_of_measurement: 'W'
state_class: measurement
device_class: power
icon: mdi:flash-outline
accuracy_decimals: 0
pin: ${pulse_pin}
# internal_filter: 100ms
on_value:
then:
- light.turn_on:
id: led_red
- delay: 0.5s
- light.turn_off:
id: led_red
filters:
# multiply value = (60 / imp value) * 1000
# - multiply: 60
- lambda: return x * ((60.0 / ${pulse_rate}) * 1000.0);
total:
name: '${name} - Total Energy'
id: sensor_total_energy
unit_of_measurement: 'kWh'
icon: mdi:circle-slice-3
state_class: total_increasing
device_class: energy
accuracy_decimals: 3
filters:
# multiply value = 1 / imp value
# - multiply: 0.001
- lambda: return x * (1.0 / ${pulse_rate});
# Total day usage
- platform: total_daily_energy
name: "${name} - Daily Energy"
id: sensor_total_daily_energy
power_id: sensor_energy_pulse_meter
unit_of_measurement: 'kWh'
icon: mdi:circle-slice-3
state_class: total_increasing
device_class: energy
accuracy_decimals: 3
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
text_sensor:
- platform: wifi_info
ip_address:
name: "${name} IP Address"
ssid:
name: "${name} Connected SSID"
bssid:
name: "${name} Connected BSSID"
wifi:
id: component_wifi
ssid: "${wifi_ssid}"
password: "${wifi_password}"
reboot_timeout: 10min
ap:
ssid: "${name}"
password: "${wifi_ap_password}"
esphome:
name: "${slug}"
comment: "${description}"
build_path: "./.build/${slug}/"
esp32:
board: nodemcu-32s
uart:
rx_pin: RX
baud_rate: 4800
binary_sensor:
- platform: status
name: ${name} Status
output:
# - platform: gpio
# pin: GPIO5
# id: output_blue
- platform: gpio
pin: GPIO2
id: output_red
- platform: gpio
pin: GPIO4
id: output_green
light:
- platform: binary
internal: true
id: led_red
name: Red
output: output_red
status_led:
pin:
number: GPIO5
web_server:
id: component_web_server
port: 80
local: true