From 256c4ad82cd1cf4f0b0867c18417e5d53d2a4920 Mon Sep 17 00:00:00 2001 From: Bert Huijben Date: Wed, 24 Jul 2024 16:59:46 +0200 Subject: [PATCH] Enhancement: Add score to trip model (#346) --- mytoyota/models/trips.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mytoyota/models/trips.py b/mytoyota/models/trips.py index 6cce8ed0..b8e7fcff 100644 --- a/mytoyota/models/trips.py +++ b/mytoyota/models/trips.py @@ -166,6 +166,20 @@ def average_fuel_consumed(self) -> float: return 0.0 + @property + def score(self) -> float: + """The (hybrid) score for the trip. + + Returns + ------- + float: The hybrid score for the trip + + """ + if self._trip.scores and self._trip.scores.global_: + return self._trip.scores.global_ + + return 0.0 + @property def route(self) -> Optional[List[Tuple[float, float]]]: """The route taken.