Skip to content

Commit

Permalink
Update sensor.py
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-svrts authored Jan 16, 2025
1 parent bab078b commit 9cb294d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions custom_components/blossom_be/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ def native_value(self) -> str | datetime | None:
parts = data.split("; info: ")
if len(parts) > 1:
return parts[0].strip() # Return just the status

if self._parameter == "home-charging-session.session.status":
# Controleer op None of unknown en vervang door NOT_ACTIVE
if data in [None, "unknown"]:
return "NOT_ACTIVE"
return data

if self._parameter == "home-charging-session.session.kWh":
# Sessie actief? Retourneer huidige waarde, anders behoud laatste
session_active = self.coordinator.data.get("home-charging-session", {}).get("session", {}).get("status") == "IN_PROGRESS"
if session_active:
self._last_known_consumption = data # Bewaar de huidige waarde
return self._last_known_consumption if hasattr(self, "_last_known_consumption") else 0



# Default return: raw data
return data
Expand Down

0 comments on commit 9cb294d

Please sign in to comment.