Fix Sonarr and Radarr divide by zero (#10101)
* Fix Sonarr and Radarr divide by zero * Fixes for hound * Clean up Radarr diskspace
This commit is contained in:
1 parent
45e140149b
commit
2a2a106e62
2 files changed
+8
-8
No files matched your search
@@ -133,14 +133,12 @@ class RadarrSensor(Entity):
|
||||
attributes[command['name']] = command['state']
|
||||
elif self.type == 'diskspace':
|
||||
for data in self.data:
|
||||
free_space = to_unit(data['freeSpace'], self._unit)
|
||||
total_space = to_unit(data['totalSpace'], self._unit)
|
||||
percentage_used = (0 if total_space == 0
|
||||
else free_space / total_space * 100)
|
||||
attributes[data['path']] = '{:.2f}/{:.2f}{} ({:.2f}%)'.format(
|
||||
to_unit(data['freeSpace'], self._unit),
|
||||
to_unit(data['totalSpace'], self._unit),
|
||||
self._unit, (
|
||||
to_unit(data['freeSpace'], self._unit) /
|
||||
to_unit(data['totalSpace'], self._unit) * 100
|
||||
)
|
||||
)
|
||||
free_space, total_space, self._unit, percentage_used)
|
||||
elif self.type == 'movies':
|
||||
for movie in self.data:
|
||||
attributes[to_key(movie)] = movie['downloaded']
|
||||
|
||||
Reference in new issue
Block a user