Fix coronavirus worldwide sum (#36737)
Co-authored-by: Franck Nijhof <git@frenck.dev> Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
82058f0b50
commit
149a3165e6
2 changed files with 15 additions and 3 deletions
|
@ -51,9 +51,14 @@ class CoronavirusSensor(Entity):
|
|||
def state(self):
|
||||
"""State of the sensor."""
|
||||
if self.country == OPTION_WORLDWIDE:
|
||||
return sum(
|
||||
getattr(case, self.info_type) for case in self.coordinator.data.values()
|
||||
)
|
||||
sum_cases = 0
|
||||
for case in self.coordinator.data.values():
|
||||
value = getattr(case, self.info_type)
|
||||
if value is None:
|
||||
continue
|
||||
sum_cases += value
|
||||
|
||||
return sum_cases
|
||||
|
||||
return getattr(self.coordinator.data[self.country], self.info_type)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue