Skip to content

Commit

Permalink
Allow negative values in energy used this hour.
Browse files Browse the repository at this point in the history
  • Loading branch information
epaulsen committed Aug 6, 2023
1 parent 1d67eb0 commit a580851
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion custom_components/energytariff/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,18 @@ def calculate_top_three(state: EnergyData, top_three: Any) -> Any:

localtime = dt.as_local(state.timestamp)

energy_used = state.energy_consumed

# Solar or wind production can cause the energy meter to have negative values
# Set this to 0, as tariffs are only for consumption and we don't have negative
# tariff values in the tariff config section.
if energy_used < 0:
energy_used = 0

consumption = {
"day": localtime.day,
"hour": localtime.hour,
"energy": state.energy_consumed,
"energy": energy_used,
}

# Case 1:Empty list. Uncricitally add, calculate level and return
Expand Down

0 comments on commit a580851

Please sign in to comment.