Fix get_power_hours_from_components
This commit is contained in:
parent
e6223420d2
commit
448287248e
|
@ -12,6 +12,7 @@ class DummyEnvironmentalImpactAlgorithm(EnvironmentImpactAlgorithm):
|
|||
avg_watts = 40 # Arbitrary laptop average consumption
|
||||
co2_per_kwh = 0.475
|
||||
power_on_hours = self.get_power_on_hours_from(device)
|
||||
|
||||
energy_kwh = (power_on_hours * avg_watts) / 1000
|
||||
co2_emissions = energy_kwh * co2_per_kwh
|
||||
current_dir = os.path.dirname(__file__)
|
||||
|
@ -23,8 +24,8 @@ class DummyEnvironmentalImpactAlgorithm(EnvironmentImpactAlgorithm):
|
|||
# TODO how do I check if the device is a legacy workbench? Is there a better way?
|
||||
is_legacy_workbench = False if device.last_evidence.inxi else True
|
||||
if not is_legacy_workbench:
|
||||
storage_components = device.components[9]
|
||||
str_time = storage_components.get('time of used', -1)
|
||||
storage_components = next((comp for comp in device.components if comp['type'] == 'Storage'), None)
|
||||
str_time = storage_components.get('time of used', "")
|
||||
else:
|
||||
str_time = ""
|
||||
uptime_in_hours = self.convert_str_time_to_hours(
|
||||
|
|
Loading…
Reference in a new issue