klaasnicolaas / home-assistant-glow

⚡ The power of energy measurements in your house
https://glow-energy.io/
MIT License
1.01k stars 149 forks source link

Values reported by Glow much higher #33

Open Joeboyc2 opened 2 years ago

Joeboyc2 commented 2 years ago

Hi All,

I've recently setup the glow on my electricity meter and all seemed to be working well. However, I have noticed that the power consumption readings are going up much quicker than I would expect.

My meter runs at a rate of 4000 blinks per kWh, and i have adjusted my config to that, but when looking in the logs i can see it is tracking each of these blinks and pushing the number up pretty quickly, rather then small increments.

Here is some output from my logs:

[09:48:15][D][sensor:131]: 'House - Power consumption': Sending state 320.39871 W with 0 decimals of accuracy
[09:48:15][D][sensor:131]: 'House - Total energy': Sending state 0.14925 kWh with 3 decimals of accuracy
[09:48:18][D][sensor:131]: 'House - Total energy': Sending state 0.14950 kWh with 3 decimals of accuracy
[09:48:20][D][sensor:131]: 'House - Power consumption': Sending state 319.03583 W with 0 decimals of accuracy
[09:48:20][D][sensor:131]: 'House - Total energy': Sending state 0.14975 kWh with 3 decimals of accuracy
[09:48:23][D][sensor:131]: 'House - Power consumption': Sending state 320.39871 W with 0 decimals of accuracy
[09:48:23][D][sensor:131]: 'House - Total energy': Sending state 0.15000 kWh with 3 decimals of accuracy
[09:48:26][D][sensor:131]: 'House - Power consumption': Sending state 321.77332 W with 0 decimals of accuracy
[09:48:26][D][sensor:131]: 'House - Total energy': Sending state 0.15025 kWh with 3 decimals of accuracy
[09:48:29][D][sensor:131]: 'House - Power consumption': Sending state 321.65833 W with 0 decimals of accuracy
[09:48:29][D][sensor:131]: 'House - Total energy': Sending state 0.15050 kWh with 3 decimals of accuracy
[09:48:32][D][sensor:131]: 'House - Power consumption': Sending state 320.51282 W with 0 decimals of accuracy
[09:48:32][D][sensor:131]: 'House - Total energy': Sending state 0.15075 kWh with 3 decimals of accuracy
[09:48:34][D][sensor:131]: 'House - Power consumption': Sending state 322.69629 W with 0 decimals of accuracy
[09:48:34][D][sensor:131]: 'House - Total energy': Sending state 0.15100 kWh with 3 decimals of accuracy
[09:48:37][D][sensor:131]: 'House - Power consumption': Sending state 320.51282 W with 0 decimals of accuracy
[09:48:37][D][sensor:131]: 'House - Total energy': Sending state 0.15125 kWh with 3 decimals of accuracy
[09:48:40][D][sensor:131]: 'House - Power consumption': Sending state 321.77332 W with 0 decimals of accuracy
[09:48:40][D][sensor:131]: 'House - Total energy': Sending state 0.15150 kWh with 3 decimals of accuracy
[09:48:43][D][sensor:131]: 'House - Power consumption': Sending state 321.65833 W with 0 decimals of accuracy
[09:48:43][D][sensor:131]: 'House - Total energy': Sending state 0.15175 kWh with 3 decimals of accuracy
[09:48:46][D][sensor:131]: 'House - Power consumption': Sending state 320.51282 W with 0 decimals of accuracy
[09:48:46][D][sensor:131]: 'House - Total energy': Sending state 0.15200 kWh with 3 decimals of accuracy
[09:48:48][D][sensor:131]: 'House - Power consumption': Sending state 320.28470 W with 0 decimals of accuracy
[09:48:48][D][sensor:131]: 'House - Total energy': Sending state 0.15225 kWh with 3 decimals of accuracy
[09:48:51][D][sensor:131]: 'House - Power consumption': Sending state 320.39871 W with 0 decimals of accuracy
[09:48:51][D][sensor:131]: 'House - Total energy': Sending state 0.15250 kWh with 3 decimals of accuracy
[09:48:54][D][sensor:131]: 'House - Total energy': Sending state 0.15275 kWh with 3 decimals of accuracy
[09:48:57][D][sensor:131]: 'House - Total energy': Sending state 0.15300 kWh with 3 decimals of accuracy
[09:49:00][D][sensor:131]: 'House - Power consumption': Sending state 319.14893 W with 0 decimals of accuracy
[09:49:00][D][sensor:131]: 'House - Total energy': Sending state 0.15325 kWh with 3 decimals of accuracy
[09:49:02][D][sensor:131]: 'House - Power consumption': Sending state 320.39871 W with 0 decimals of accuracy
[09:49:02][D][sensor:131]: 'House - Total energy': Sending state 0.15350 kWh with 3 decimals of accuracy

so when looking at my energy usage via the energy dashboard it reports really high usage over each half hour, where as my energy company dashboard shows a much lower readings (when looking at yesterday) image

I will need to wait until tomorrow to get the true usage data from my energy provider for todays usage but i will update this ticket then, to give a good example.

I think the issue here must be due to the pulses but im not 100% sure how the calculation is being done

klaasnicolaas commented 2 years ago

The piece of logs looks fine, I think there was some hypersensitivity of the sensor at that moment. So that causes a high kWh value in your energy dashboard. Maybe make the sensor less sensitive and/or make sure that the sensor is in a dark room.

Joeboyc2 commented 2 years ago

Hey @klaasnicolaas , The sensor is located under my stairs in a cupboard, and I am using the 3d printed sensor housing, i can try to adjust the sensor itself using the pot, but so far it seems to track the blips correctly. No idea what happened at 4am this morning lol, everyone in my house was asleep

klaasnicolaas commented 2 years ago

Maybe it was a one-time thing after all and is it okay now?

Joeboyc2 commented 2 years ago

Hey Klaas,

I think there must have been an issue with the code.

I recreated the config using the current yaml on github and reflashed.

It works better now but still not 100% correct.

I'll need to look in to why the usage on the energy dashboard is still higher then what I see on my energy account, maybe the calculation is still a bit off

On Mon, 30 Aug 2021, 02:18 Klaas Schoute, @.***> wrote:

Maybe it was a one-time thing after all and is it okay now?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/klaasnicolaas/home-assistant-glow/issues/33#issuecomment-907936549, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6SOLXWTTJQN7MS454JB4TT7LL6LANCNFSM5C65JMXQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

estevez-dev commented 2 years ago

Looks like I have the same or similar issue. I've added a service to reset the energy total and wrote down my electricity meter data to compare it with the glow.

api:
  password: ********
  services:
    - service: reset_total
      then:
        - pulse_meter.set_total_pulses:
            id: electricity_pulse_meter
            value: 0

In 12 hours electricity meter reported 12 kWh consumed while the glow reported 48kWh. I'll continue observation to find out is it always 4 times differences or the dependence is nonlinear.

My electricity meter blinks at 3200 imp / kWh.

@Joeboyc2 , please, let me know if you found a reason of your issue. Thanks.

Joeboyc2 commented 2 years ago

Hi Yegor,

I'm still having issue with the totals as they are much higher than my energy account reports and I even tried to change the pulse count to a much higher value 8000 (where as my meter reports 4000) but still no luck.

I could just be that meter I have is misscalculating as I moved provider a while ago.

I need to revisit this to be honest as it throws me off when I see ive used £100+ electricity (in ha dashboard) in an afternoon lol

I should have some time to reassess soon, will get back to you

On Sun, 24 Oct 2021, 10:09 Yegor Vialov, @.***> wrote:

Looks like I have the same or similar issue. I've added a service to reset the energy total and wrote down my electricity meter data to compare it with the glow.

api: password: **** services:

  • service: reset_total then:
    • pulse_meter.set_total_pulses: id: electricity_pulse_meter value: 0

In 12 hours electricity meter reported 12 kWh consumed while the glow reported 48kWh. I'll continue observation to find out is it always 4 times differences or the dependence is nonlinear.

My electricity meter blinks at 3200 imp / kWh.

@Joeboyc2 https://github.com/Joeboyc2 , please, let me know if you found a reason of your issue. Thanks.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/klaasnicolaas/home-assistant-glow/issues/33#issuecomment-950288625, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6SOLVQN7XJVROM5CPJZVLUIPELPANCNFSM5C65JMXQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

sillymoi commented 2 years ago

Hi, I'm using ESP8266 with the photodiode, meter is giving off 500 pulses/kWh. I'm seeing a similar issue, Hass typically reports 30% higher consumption which led me to believe that the electricity meter is reporting kVAh and not kWh but according to the documentation it is correctly reporting kWh. Yesterday i got 2x greater value reported for the day compared to the electricity company daily use. I tried keeping an eye on the setup and I clearly see ESP8266 blinking at the same time as the meter does so it seems the number of pulses is correct, perhaps it's related to the pulse width.

One other thing - I was getting values of around 150000W earlier (now i filtered out everything > 100000 with a lambda), depending on the position of the LED it would vary between 140000-150000... might be related but not sure how to diagnose it, suggestions are welcome :)

estevez-dev commented 2 years ago

Hi @sillymoi . That's called noise. Those photodiode boards are very noisy when switching their state. This electromagnetic noise is counted as pulses and you are getting the wrong measurements. The only way to ditch it is to not accept any pulses after one was detected. Try to uncomment this line:

# internal_filter: 100ms

I'm done with this type of electricity consumption monitoring as my meter can blink too fast to filter out any noise.

sillymoi commented 2 years ago

Hi @estevez-dev - of course, should've thought it through.. I cut off the high frequency noise with the if-then lambda but still have lower frequencies left, plus I probably did it in the wrong place (power device instead of total energy device used by Hass). It made more sense when I read about the difference between pulse_counter and pulse_meter.

My meter pulses a bit slower, hopefully the 100ms filter will help.

EspressoNerd commented 2 years ago

Looks like I have the same or similar issue. I've added a service to reset the energy total and wrote down my electricity meter data to compare it with the glow.

api:
  password: ********
  services:
    - service: reset_total
      then:
        - pulse_meter.set_total_pulses:
            id: electricity_pulse_meter
            value: 0

In 12 hours electricity meter reported 12 kWh consumed while the glow reported 48kWh. I'll continue observation to find out is it always 4 times differences or the dependence is nonlinear.

My electricity meter blinks at 3200 imp / kWh.

@Joeboyc2 , please, let me know if you found a reason of your issue. Thanks.

This code fragment is great, @estevez-dev. May I ask you how I will be able to set the "Total Energy" to a value I enter in the web page? I would like the counter to reflect the value being displayed at the electricity meter.

klaasnicolaas commented 2 years ago

That is currently not possible, you can only reset the value. Also, the service name in the default yaml file has been changed.

I wonder how useful it is to enter the value of your electricity meter, it's a nice idea, but at the moment that value will always reset when you update the firmware or interrupt the power. That would have to be solved first if you really want to benefit from it 🤔

EspressoNerd commented 2 years ago

Resetting the value after rebooting / firmware update to the value it had before is more in sync with the understanding of a meter as a monotonically increasing value. Therefore I think it might be a good idea to reset the counter.

cholek3 commented 1 year ago

I also have an issue with energy spikes (nearly 1.000.000W 😂) i have uncommented internal_filter: 100ms and I will see if that helps. Screenshot_20221112_070305_Home Assistant

When it comes to applying total meter reading to total energy value, you can either update that adding meter reading to the total value lambda, when you flash the ESP (see below), but you have to be quick with that. (1 on the photo).

Or create text input field in home assistant and input energy total energy value from energy monitor, then simply add this value to total energy value from ESP (2 on the photo). Its a work around, but seems to work. Hopefully i explained that right. image-5 image-4 image-6

niemtec commented 1 year ago

I still face a similar issue. The readings seem to be going crazy even if the sensor itself isn't showing much activity. The LED doesn't blink almost at all, is there a way to filter out noise?

klaasnicolaas commented 1 year ago

Sounds like the photodiode is set too sensitive 😉

niemtec commented 1 year ago

It's strange I've lowered it as much as it goes, the LED doesn't blink at all and yet readings are off the charts.

cholek3 commented 1 year ago

@niemtec Possibly you may have the faulty photodiode (is it soldered right way round?). But to rule out code, provide your code. Also, did you uncomment "internal_filter" as mentioned above?

niemtec commented 1 year ago

@cholek3 I have tried this with two photodiodes and had the same results. I checked them against the photo in README and appears to be soldered on correctly. It doesn't seem to react to the energy meters blinks at all and yet measurements are off the charts.

I'm getting daily readings of about 255.273 kWh which sounds completely wrong.

---
# 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:
  device_name: home-assistant-glow
  friendly_name: House
  project_version: "3.1.0"
  device_description: "Measure your energy consumption with the pulse LED on your smart meter"
  pulse_pin: GPIO12
  status_led: GPIO5

  # imp/kWh rate ⬇ #
  pulse_rate: '1000'

  # Webserver credentials ⬇ #
  web_username: 'glow'
  web_password: 'esphome'

dashboard_import:
  package_import_url: github://klaasnicolaas/home-assistant-glow/home_assistant_glow.yaml

esphome:
  name: '${device_name}'
  comment: '${device_description}'
  project:
    name: "klaasnicolaas.home-assistant-glow"
    version: "${project_version}"
  compile_process_limit: 1

# Choose the right Platform
# esp32: https://esphome.io/components/esp32.html
# esp8266: https://esphome.io/components/esp8266.html
esp32:
  board: esp32dev

# WiFi credentials #
wifi:
  ssid: 'name'       # Enter your WiFi SSID here. Example: `ssid: 'your_network_name'`
  password: 'blablablabla'   # Enter your wifi password here. Example: `password: 'abcde123456'`

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: '${device_name}'

captive_portal:

# Enable logging
logger:

# Enable improv over serial
improv_serial:

# Enable Home Assistant API
api:
  services:
    - service: reset_total_energy
      then:
        - button.press:
            id: button_reset_total

ota:
  safe_mode: false
  reboot_timeout: 5min
  num_attempts: 5

web_server:
  port: 80
  auth:
    username: '${web_username}'
    password: '${web_password}'

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 for connection
status_led:
  pin:
    # Blue LED
    number: ${status_led}

button:
  - platform: restart
    name: "Restart - Glow"
  - platform: template
    name: "Reset - Total Energy"
    id: button_reset_total
    on_press:
      - pulse_meter.set_total_pulses:
          id: sensor_energy_pulse_meter
          value: 0

# Sensors for ESP version and WIFI information
text_sensor:
  # Installed version
  - platform: template
    name: "Glow - Installed version"
    id: glow_version
    icon: "mdi:label-outline"
    entity_category: diagnostic
    lambda: |-
      return {"${project_version}"};
    update_interval: 6h
  - platform: version
    hide_timestamp: true
    name: '${friendly_name} - ESPHome Version'
  - platform: wifi_info
    ip_address:
      name: '${friendly_name} - IP Address'
      icon: mdi:wifi
    ssid:
      name: '${friendly_name} - Connected SSID'
      icon: mdi:wifi-strength-2

sensor:
  # WiFi signal
  - platform: wifi_signal
    name: "${friendly_name} - WiFi Signal"
    update_interval: 120s

  # Pulse meter
  - platform: pulse_meter
    name: '${friendly_name} - Power Consumption in kW'
    id: sensor_energy_pulse_meter
    unit_of_measurement: 'kW'
    state_class: measurement
    device_class: power
    icon: mdi:flash-outline
    accuracy_decimals: 0
    pin: ${pulse_pin}
    internal_filter: 100ms
    internal_filter_mode: 'PULSE'
    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});
    total:
      name: '${friendly_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: 2
      filters:
        # multiply value = 1 / imp value
        # - multiply: 0.001
        - lambda: return x * (1.0 / ${pulse_rate});
  # Total day useage
  - platform: total_daily_energy
    name: '${friendly_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: 2
    filters:
      # Multiplication factor from W to kW is 0.001
      - multiply: 0.001

# Enable time component to reset energy at midnight
# https://esphome.io/components/time.html#home-assistant-time-source
time:
  - platform: homeassistant
    id: homeassistant_time
yarpsa commented 9 months ago

I have project_version: "4.0.0" and I keep getting 270,000 - 285,000kWh spikes in House - Power Consumption

sparkyws commented 7 months ago

I have project_version: "4.0.0" and I keep getting 270,000 - 285,000kWh spikes in House - Power Consumption

Change to GPIO26 and see if that fixes the issue

https://github.com/klaasnicolaas/home-assistant-glow/issues/300

stackner commented 7 months ago

Same issue here. anyone had any luck?

tenacioustechie commented 1 week ago

I'm having this issue too...

The 'W' power consumption value seems correct. Its the 2 Total values it provides that seem inordinately higher than they should be

klaasnicolaas commented 1 week ago
  • I haven't found any guidance on calibrating the sensor
  • I can't find where this line of code might help # internal_filter: 100ms if it still might help

There are no instructions yet, but it could certainly be added to the website. This also applies to the use of the internal_filter, information about this can mainly be found in the issues.

./Klaas