@@ -61,7 +61,7 @@ def output_pa
61
61
# Find date exactly n years before date_to.
62
62
year_count = ( entries_period / 365 ) . to_i
63
63
start_date = ( date_to - year_count . years ) . strftime ( '%Y%m%d' )
64
- query_params = { :sid1 => self . id , :date_from => start_date , :date_to => self . date_to }
64
+ query_params = { :sid1 => self . id , :df => start_date , :dt => self . date_to }
65
65
stats = PvOutputWrapper ::Request . get_statistic ( query_params )
66
66
stats [ 'total_output' ] . to_i / year_count
67
67
end
@@ -116,9 +116,8 @@ def self.search(query)
116
116
params = { :q => query ,
117
117
:country => 'Australia' }
118
118
request = PvOutputWrapper ::Request . new ( Rails . application . secrets . pvo_api_key ,
119
- Rails . application . secrets . pvo_system_id )
119
+ Rails . application . secrets . pvo_system_id )
120
120
response = request . search ( params ) . body
121
- # response = self.request('search', params)
122
121
response . chomp!
123
122
results = [ ]
124
123
keys = [ 'name' , 'system_watts' , 'postcode' , 'orientation' , 'entries' , 'last_entry' , 'id' , 'panel' , 'inverter' , 'distance' , 'latitude' , 'longitude' ]
@@ -138,10 +137,12 @@ def self.search(query)
138
137
end
139
138
140
139
# @param [Fixnum]
141
- # TODO handle nil/empty resultset
140
+ # TODO: handle nil/empty resultset
142
141
# @return [Hash] of system info data.
143
142
def self . get_system ( id )
144
- response = self . request ( 'getsystem' , { :sid1 => id } )
143
+ request = PvOutputWrapper ::Request . new ( Rails . application . secrets . pvo_api_key ,
144
+ Rails . application . secrets . pvo_system_id )
145
+ response = request . get_system ( { :sid1 => id } ) . body
145
146
keys = %w( system_watts panel_count panel_watts orientation tilt shade install_date sec_panel_count sec_panel_watts sec_bearing sec_tilt )
146
147
results_array = response . split ( /,/ )
147
148
selected_results = results_array . values_at ( 1 , 3 , 4 , 9 , 10 , 11 , 12 , 16 , 17 , 18 , 19 )
@@ -168,10 +169,13 @@ def get_output
168
169
results
169
170
end
170
171
172
+ # @arg [Hash]
171
173
# @return [Hash<String, >] system data or nil values upon failure.
172
174
# Keep as class method for flexibility.
173
175
def self . get_statistic ( query_params = { } )
174
- response = self . request ( 'getstatistic' , query_params )
176
+ request = PvOutputWrapper ::Request . new ( Rails . application . secrets . pvo_api_key ,
177
+ Rails . application . secrets . pvo_system_id )
178
+ response = request . get_statistic ( query_params ) . body
175
179
# total_output is in watt hours
176
180
keys = [ 'total_output' , 'efficiency' , 'date_from' , 'date_to' ]
177
181
results_array = response . split ( /,/ )
0 commit comments