Skip to content

Commit

Permalink
Bugfixes: 1. Don't overwrite max usage units in the tariffs we produc…
Browse files Browse the repository at this point in the history
…e. 2. Only throw an error if the max usage unit is not kWh AND a max usage value is provided. The units apply to the max value usage only, the rate value is always $/kWh; see the OpenEI URDB website for confirmation.
  • Loading branch information
shorowit committed Oct 16, 2024
1 parent 5c3fc81 commit 2440940
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
12 changes: 4 additions & 8 deletions ReportUtilityBills/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -598,20 +598,16 @@ def get_utility_rates(hpxml_path, fuels, utility_rates, bill_scenario, pv_monthl
rate.energy_weekday_schedule = tariff[:energyweekdayschedule]
rate.energy_weekend_schedule = tariff[:energyweekendschedule]

if rate.energy_rate_structure.collect { |r| r.collect { |s| s.keys.include?(:rate) } }.flatten.any? { |t| !t }
if rate.energy_rate_structure.collect { |r| r.collect { |s| !s.keys.include?(:rate) } }.flatten.any?
warnings << "#{tariff_name}: Every tier must contain a rate; utility bills will not be calculated."
end

if rate.energy_rate_structure.collect { |r| r.collect { |s| s.keys } }.flatten.uniq.include?(:sell)
warnings << "#{tariff_name}: No tier may contain a sell key; utility bills will not be calculated."
warnings << "#{tariff_name}: Tariffs with sell rates are not currently supported; utility bills will not be calculated."
end

if rate.energy_rate_structure.collect { |r| r.collect { |s| s.keys.include?(:unit) } }.flatten.any? { |t| !t }
warnings << "#{tariff_name}: Every tier must contain a unit; utility bills will not be calculated."
end

if rate.energy_rate_structure.collect { |r| r.collect { |s| s[:unit] == 'kWh' } }.flatten.any? { |t| !t }
warnings << "#{tariff_name}: All rates must be in units of kWh; utility bills will not be calculated."
if rate.energy_rate_structure.collect { |r| r.collect { |s| s[:unit] != 'kWh' && s.keys.include?(:max) } }.flatten.any?
warnings << "#{tariff_name}: Only max usage units of kWh are currently supported; utility bills will not be calculated."
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions ReportUtilityBills/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.1</schema_version>
<name>report_utility_bills</name>
<uid>ca88a425-e59a-4bc4-af51-c7e7d1e960fe</uid>
<version_id>3d2f01b2-edf3-4915-ae9c-67503d6833e7</version_id>
<version_modified>2024-10-16T21:07:31Z</version_modified>
<version_id>ec7741e4-75b1-4c66-b40a-21ef0e5aa8f1</version_id>
<version_modified>2024-10-16T22:56:39Z</version_modified>
<xml_checksum>15BF4E57</xml_checksum>
<class_name>ReportUtilityBills</class_name>
<display_name>Utility Bills Report</display_name>
Expand Down Expand Up @@ -180,7 +180,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>FB222527</checksum>
<checksum>4D23174A</checksum>
</file>
<file>
<filename>detailed_rates/README.md</filename>
Expand Down Expand Up @@ -294,7 +294,7 @@
<filename>detailed_rates/openei_rates.zip</filename>
<filetype>zip</filetype>
<usage_type>resource</usage_type>
<checksum>111E79AB</checksum>
<checksum>FCDE5F5D</checksum>
</file>
<file>
<filename>simple_rates/HouseholdConsumption.csv</filename>
Expand All @@ -318,7 +318,7 @@
<filename>util.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>D61BE969</checksum>
<checksum>22F928DB</checksum>
</file>
<file>
<filename>Contains Demand Charges.json</filename>
Expand Down
Binary file modified ReportUtilityBills/resources/detailed_rates/openei_rates.zip
Binary file not shown.
8 changes: 4 additions & 4 deletions ReportUtilityBills/resources/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -614,16 +614,16 @@ def process_usurdb(filepath)
next if rate['energyweekdayschedule'].nil? || rate['energyweekendschedule'].nil? || rate['energyratestructure'].nil?

# ignore rates without a "rate" key
next if rate['energyratestructure'].collect { |r| r.collect { |s| s.keys.include?('rate') } }.flatten.any? { |t| !t }
next if rate['energyratestructure'].collect { |r| r.collect { |s| !s.keys.include?('rate') } }.flatten.any?

# ignore rates with negative "rate" value
next if rate['energyratestructure'].collect { |r| r.collect { |s| s['rate'] >= 0 } }.flatten.any? { |t| !t }
next if rate['energyratestructure'].collect { |r| r.collect { |s| s['rate'] < 0 } }.flatten.any?

# ignore rates with a "sell" key
next if rate['energyratestructure'].collect { |r| r.collect { |s| s.keys } }.flatten.uniq.include?('sell')

# set rate units to 'kWh'
rate['energyratestructure'].collect { |r| r.collect { |s| s['unit'] = 'kWh' } }
# ignore rates where max usage is provided but max units are not 'kWh'
next if rate['energyratestructure'].collect { |r| r.collect { |s| s['unit'] != 'kWh' && s.keys.include?('max') } }.flatten.any?

residential_rates << { 'items' => [rate] }
end
Expand Down

0 comments on commit 2440940

Please sign in to comment.