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

Fix nordpool Not to return Unknown if price is exactly 0 #140647

Draft
wants to merge 17 commits into
base: dev
Choose a base branch
from
Draft
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions homeassistant/components/nordpool/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ def validate_prices(
index: int,
) -> float | None:
"""Validate and return."""
if result := func(entity)[area][index]:
return result / 1000
return None
result = func(entity)[area][index]
if result is None:
return None
if result == 0:
return 0
return result / 1000


def get_prices(
Expand Down Expand Up @@ -401,4 +404,7 @@ def __init__(
def native_value(self) -> float | None:
"""Return value of sensor."""
data = self.coordinator.get_data_current_day()
return data.area_average[self.area] / 1000
value = data.area_average.get(self.area)
if value is None:
return None
return value / 1000