Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cost reading record large increase each time Home assistant is restarted #69

Open
alfwro13 opened this issue Feb 6, 2024 · 4 comments
Assignees

Comments

@alfwro13
Copy link

alfwro13 commented Feb 6, 2024

Version of the custom_component

v.1.1.0

Configuration

energy_meter:
  daily_energy:
    source: sensor.octopus_energy_electricity_current_accumulative_consumption
    unique_id: agile_daily_energy_um
    name: Agile Daily Electricity Energy
    cycle: daily
    price_entity: sensor.octopus_energy_electricity_current_rate
  weekly_energy:
    source: sensor.octopus_energy_electricity_current_accumulative_consumption
    unique_id: agile_weekly_energy_um
    name: Agile Weekly Electricity Energy
    cycle: weekly
    price_entity: sensor.octopus_energy_electricity_current_rate
  monthly_energy:
    source: sensor.octopus_energy_electricity_current_accumulative_consumption
    name: Agile Monthly Electricity Energy
    unique_id: agile_monthly_energy_um
    cycle: monthly
    price_entity: sensor.octopus_energy_electricity_current_rate

Describe the bug

Every time Home assistant is restarted cost energy meter entities record large increase (by around £2.4) . For example today my "Agile Daily Electricity Energy Cost is £0.42. I have restarted HA and it jumped to £2.83. I use the Utility meter calibrate service to manually change it to the correct value. Here is a screenshot:
image

This started happening at around the beginning of December 2023 prior to that this was working fine.
As for my setup I run Home Assistant OS. HAOS, Supervisor and HA are always updated to the latest version usually within days of it being released. Currently running version HA Core v2024.1.6
This is only affecting the cost entities, energy consumption entities are fine.

Debug log

2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter.daily_energy
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter.daily_energy: skip utility_meter select entity
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter.daily_energy: create a single utility_meter sensor
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter: setup energy cost sensor of type from_grid
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter: create energy cost sensor for entity sensor.octopus_energy_electricity_current_accumulative_consumption
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter.daily_energy_cost: create a single utility_meter sensor
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter.weekly_energy
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter.weekly_energy: skip utility_meter select entity
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter.weekly_energy: create a single utility_meter sensor
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter: setup energy cost sensor of type from_grid
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter.weekly_energy_cost: create a single utility_meter sensor
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter.monthly_energy
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter.monthly_energy: skip utility_meter select entity
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter.monthly_energy: create a single utility_meter sensor
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter: setup energy cost sensor of type from_grid
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter.monthly_energy_cost: create a single utility_meter sensor
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter.agile_daily_export
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter.agile_daily_export: skip utility_meter select entity
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter.agile_daily_export: create a single utility_meter sensor
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter: setup energy cost sensor of type from_grid
2024-02-06 13:33:51.978 DEBUG (MainThread) [custom_components.energy_meter] Setup energy_meter: create energy cost sensor for entity sensor.shellyem_channel_1_energy_returned
@zeronounours zeronounours self-assigned this Feb 24, 2024
@zeronounours
Copy link
Owner

Hello, @alfwro13, so far, I only have suppositions on the cause of your issue. My best idea is that your source energy sensor is not providing accurately the availability status which cause issues upon restart.

Can you:

  • If you're using a template sensor for the energy sensor, ensure that availability attribute is correctly defined?
  • Check the long term statistics of your energy sensor at the time of restart and tell me the value? (you can find the stats in developer tools > statistics and then by clicking on the icon « ajust sum » of your entity)

The change you've noticed is probably due to home-assistant/core@46d6262. Prior to this, the energy cost sensor started monitoring with both energy and price sensor were ready. Now it starts only when energy sensor is ready.

I suppose the following sequence happens for you on startup :

  1. Your energy sensor become ready, but with value 0
  2. The energy_meter is loaded, creating the energy cost sensor: because the energy sensor is ready, it starts accumulating costs
  3. Your energy sensor restore its previous, good value, lets says 1000 kWh
  4. The energy cost sensor seeing this increase will consider it's a new consumption causing the jump of £2.83
  5. Only then the utility meters are loaded

If such, you might also find out a pike to 0 in the graph of the energy sensor

@zeronounours
Copy link
Owner

hello @alfwro13, is your issue solved?

@alfwro13
Copy link
Author

alfwro13 commented Dec 8, 2024

No, unfortunately the problem is still there. However I have a working workaround - I created input number helpers and when home assistant is restarted automation first writes the existing value to the input entity and when HA is back and running another automation copies that value back to the entity.

@zeronounours
Copy link
Owner

Could you also share the graph on restart of:

  • the cost sensor (the one which serves as source to your Agile Daily Electricity Energy Cost),
  • the price sensor sensor.octopus_energy_electricity_current_rate ?

Could you also share the attributes of:

  • The utility meter Agile Daily Electricity Energy Cost
  • The cost sensor
  • The consumed energy sensor sensor.octopus_energy_electricity_current_accumulative_consumption?
    You can find them in "Developer tools > State" within the table listing all entities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants