sunnycarcharger-agent 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sunnycarcharger/agent/fronius.rb +25 -6
- data/lib/sunnycarcharger/agent/invertor_data.rb +6 -2
- data/lib/sunnycarcharger/agent/version.rb +1 -1
- data/test/fixtures/vcr_cassettes/fronius-midday.yml +99 -0
- data/test/fixtures/vcr_cassettes/fronius-night.yml +179 -0
- data/test/sunnycarcharger/agent/fronius_test.rb +18 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74fbebb7d35be601f1f1c0f5c2bf102f71fbf5c571e709fb86253de8025dc02c
|
4
|
+
data.tar.gz: '008397000fb1cf8cac6c17e4cf427fa5f1a6a0f904b1968cc6d02b2c8bd6052c'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2093e938beaa6e0a89f540505ba364aeb975343cd5f8eb5bd03df2dba77006c6ae189c0993f83bc9cfb71dce49a358cd3bc057b42c10c01a684010144f99d6b
|
7
|
+
data.tar.gz: abc63c83d4a0d46305b22a2f264649cfa0ebe7b2520e96c8c56e1f498d6bfdf77058a16684596b60bc1299d7f82008327e3939986bb11498500ee14a01790103
|
@@ -16,20 +16,39 @@ class Sunnycarcharger::Agent::Fronius
|
|
16
16
|
conn.response :raise_error
|
17
17
|
# conn.request :retry, retry_options if retry_options # Must be registered after :raise_error
|
18
18
|
conn.adapter Faraday.default_adapter
|
19
|
-
conn.options.timeout =
|
19
|
+
conn.options.timeout = 3
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
def fetch
|
24
|
-
path = "/solar_api/v1/GetPowerFlowRealtimeData.fcgi"
|
25
|
-
response = client.get(path).body
|
26
24
|
data = Sunnycarcharger::Agent::InvertorData.new
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
|
26
|
+
response = client.get("/solar_api/v1/GetPowerFlowRealtimeData.fcgi").body
|
27
|
+
body = response.dig("Body", "Data", "Site")
|
28
|
+
data.power_from_grid = body.dig("P_Grid").to_i
|
29
|
+
data.power_to_load = -1 * body.dig("P_Load").to_i
|
30
|
+
data.power_from_solar = body.dig("P_PV").to_i
|
31
|
+
data.solar_energy_today = body.dig("E_Day").to_i
|
32
|
+
|
33
|
+
begin
|
34
|
+
response = client.get("/solar_api/v1/GetMeterRealtimeData.cgi?Scope=System").body
|
35
|
+
body = response.dig("Body", "Data", "0")
|
36
|
+
data.energy_consumed = body.dig("EnergyReal_WAC_Sum_Consumed").to_i
|
37
|
+
data.energy_produced = body.dig("EnergyReal_WAC_Sum_Produced").to_i
|
38
|
+
rescue => e
|
39
|
+
puts "Error fetching energy_consumed and energy_produced: #{e}"
|
40
|
+
end
|
41
|
+
|
30
42
|
data
|
31
43
|
end
|
32
44
|
|
45
|
+
# {"Manufacturer"=>"Fronius", "Model"=>"CCS WattNode WND-3D-480-MB", "Serial"=>"123456"}
|
46
|
+
def inverter_details
|
47
|
+
response = client.get("/solar_api/v1/GetMeterRealtimeData.cgi?Scope=System").body
|
48
|
+
body = response.dig("Body", "Data", "0")
|
49
|
+
body.dig("Details")
|
50
|
+
end
|
51
|
+
|
33
52
|
def connected?
|
34
53
|
fetch
|
35
54
|
true
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class Sunnycarcharger::Agent::InvertorData
|
2
|
-
attr_accessor :power_from_grid, :power_to_load, :power_from_solar
|
2
|
+
attr_accessor :power_from_grid, :power_to_load, :power_from_solar, :solar_energy_today
|
3
|
+
attr_accessor :energy_consumed, :energy_produced
|
3
4
|
|
4
5
|
def power_to_grid
|
5
6
|
-power_from_grid
|
@@ -9,7 +10,10 @@ class Sunnycarcharger::Agent::InvertorData
|
|
9
10
|
{
|
10
11
|
power_from_grid: power_from_grid,
|
11
12
|
power_to_load: power_to_load,
|
12
|
-
power_from_solar: power_from_solar
|
13
|
+
power_from_solar: power_from_solar,
|
14
|
+
solar_energy_today: solar_energy_today,
|
15
|
+
energy_consumed: energy_consumed,
|
16
|
+
energy_produced: energy_produced
|
13
17
|
}
|
14
18
|
end
|
15
19
|
end
|
@@ -77,4 +77,103 @@ http_interactions:
|
|
77
77
|
}
|
78
78
|
}
|
79
79
|
recorded_at: Sun, 09 Jul 2023 04:03:53 GMT
|
80
|
+
- request:
|
81
|
+
method: get
|
82
|
+
uri: http://192.168.86.26/solar_api/v1/GetMeterRealtimeData.cgi?Scope=System
|
83
|
+
body:
|
84
|
+
encoding: US-ASCII
|
85
|
+
string: ''
|
86
|
+
headers:
|
87
|
+
User-Agent:
|
88
|
+
- sunnycarcharger-agent
|
89
|
+
response:
|
90
|
+
status:
|
91
|
+
code: 200
|
92
|
+
message: OK
|
93
|
+
headers:
|
94
|
+
content-type:
|
95
|
+
- application/json
|
96
|
+
cache-control:
|
97
|
+
- no-cache, no-store, must-revalidate
|
98
|
+
pragma:
|
99
|
+
- no-cache
|
100
|
+
expires:
|
101
|
+
- '0'
|
102
|
+
content-length:
|
103
|
+
- '2705'
|
104
|
+
date:
|
105
|
+
- Sun, 30 Jul 2023 12:16:43 GMT
|
106
|
+
server:
|
107
|
+
- webserver
|
108
|
+
body:
|
109
|
+
encoding: UTF-8
|
110
|
+
string: |
|
111
|
+
{
|
112
|
+
"Body" : {
|
113
|
+
"Data" : {
|
114
|
+
"0" : {
|
115
|
+
"Current_AC_Phase_1" : 0.18578459322452545,
|
116
|
+
"Current_AC_Phase_2" : 2.0522370338439941,
|
117
|
+
"Current_AC_Phase_3" : 0,
|
118
|
+
"Current_AC_Sum" : 2.2380216270685196,
|
119
|
+
"Details" : {
|
120
|
+
"Manufacturer" : "Fronius",
|
121
|
+
"Model" : "CCS WattNode WND-3D-480-MB",
|
122
|
+
"Serial" : "745995"
|
123
|
+
},
|
124
|
+
"Enable" : 1,
|
125
|
+
"EnergyReal_WAC_Minus_Absolute" : 49028617,
|
126
|
+
"EnergyReal_WAC_Phase_1_Consumed" : 5359053,
|
127
|
+
"EnergyReal_WAC_Phase_1_Produced" : 30984743,
|
128
|
+
"EnergyReal_WAC_Phase_2_Consumed" : 18531328,
|
129
|
+
"EnergyReal_WAC_Phase_2_Produced" : 21950501,
|
130
|
+
"EnergyReal_WAC_Phase_3_Consumed" : 0,
|
131
|
+
"EnergyReal_WAC_Phase_3_Produced" : 0,
|
132
|
+
"EnergyReal_WAC_Plus_Absolute" : 19983755,
|
133
|
+
"EnergyReal_WAC_Sum_Consumed" : 19983755,
|
134
|
+
"EnergyReal_WAC_Sum_Produced" : 49028617,
|
135
|
+
"Frequency_Phase_Average" : 50.03289794921875,
|
136
|
+
"Meter_Location_Current" : 0,
|
137
|
+
"PowerApparent_S_Phase_1" : 43.604618072509766,
|
138
|
+
"PowerApparent_S_Phase_2" : 497.7763671875,
|
139
|
+
"PowerApparent_S_Phase_3" : 0,
|
140
|
+
"PowerApparent_S_Sum" : 541.3809814453125,
|
141
|
+
"PowerFactor_Phase_1" : 0.76950681209564209,
|
142
|
+
"PowerFactor_Phase_2" : 0.61130160093307495,
|
143
|
+
"PowerFactor_Phase_3" : 1,
|
144
|
+
"PowerFactor_Sum" : 0.62404400110244751,
|
145
|
+
"PowerReactive_Q_Phase_1" : -14.466190338134766,
|
146
|
+
"PowerReactive_Q_Phase_2" : -348.84356689453125,
|
147
|
+
"PowerReactive_Q_Phase_3" : 0,
|
148
|
+
"PowerReactive_Q_Sum" : -363.30975341796875,
|
149
|
+
"PowerReal_P_Phase_1" : 33.554050445556641,
|
150
|
+
"PowerReal_P_Phase_2" : 304.29147338867188,
|
151
|
+
"PowerReal_P_Phase_3" : 0,
|
152
|
+
"PowerReal_P_Sum" : 337.84555053710938,
|
153
|
+
"TimeStamp" : 1690719403,
|
154
|
+
"Visible" : 1,
|
155
|
+
"Voltage_AC_PhaseToPhase_12" : 414.82183837890625,
|
156
|
+
"Voltage_AC_PhaseToPhase_23" : 241.61917114257812,
|
157
|
+
"Voltage_AC_PhaseToPhase_31" : 233.82379150390625,
|
158
|
+
"Voltage_AC_Phase_1" : 234.70613098144531,
|
159
|
+
"Voltage_AC_Phase_2" : 242.55319213867188,
|
160
|
+
"Voltage_AC_Phase_3" : 0,
|
161
|
+
"Voltage_AC_Phase_Average" : 238.62966918945312
|
162
|
+
}
|
163
|
+
}
|
164
|
+
},
|
165
|
+
"Head" : {
|
166
|
+
"RequestArguments" : {
|
167
|
+
"DeviceClass" : "Meter",
|
168
|
+
"Scope" : "System"
|
169
|
+
},
|
170
|
+
"Status" : {
|
171
|
+
"Code" : 0,
|
172
|
+
"Reason" : "",
|
173
|
+
"UserMessage" : ""
|
174
|
+
},
|
175
|
+
"Timestamp" : "2023-07-30T22:16:43+10:00"
|
176
|
+
}
|
177
|
+
}
|
178
|
+
recorded_at: Sun, 30 Jul 2023 12:16:44 GMT
|
80
179
|
recorded_with: VCR 6.2.0
|
@@ -0,0 +1,179 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://192.168.86.26/solar_api/v1/GetPowerFlowRealtimeData.fcgi
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- sunnycarcharger-agent
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: OK
|
16
|
+
headers:
|
17
|
+
content-type:
|
18
|
+
- application/json
|
19
|
+
cache-control:
|
20
|
+
- no-cache, no-store, must-revalidate
|
21
|
+
pragma:
|
22
|
+
- no-cache
|
23
|
+
expires:
|
24
|
+
- '0'
|
25
|
+
content-length:
|
26
|
+
- '1105'
|
27
|
+
date:
|
28
|
+
- Sun, 30 Jul 2023 12:16:42 GMT
|
29
|
+
server:
|
30
|
+
- webserver
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: |
|
34
|
+
{
|
35
|
+
"Body" : {
|
36
|
+
"Data" : {
|
37
|
+
"Inverters" : {
|
38
|
+
"1" : {
|
39
|
+
"DT" : 102,
|
40
|
+
"E_Day" : 34470,
|
41
|
+
"E_Total" : 40344200,
|
42
|
+
"E_Year" : 7083963.5,
|
43
|
+
"P" : 0
|
44
|
+
},
|
45
|
+
"2" : {
|
46
|
+
"DT" : 102,
|
47
|
+
"E_Day" : 27664,
|
48
|
+
"E_Total" : 41063300,
|
49
|
+
"E_Year" : 6892509.5,
|
50
|
+
"P" : 0
|
51
|
+
}
|
52
|
+
},
|
53
|
+
"Site" : {
|
54
|
+
"E_Day" : 62134,
|
55
|
+
"E_Total" : 81407500,
|
56
|
+
"E_Year" : 13976473,
|
57
|
+
"Meter_Location" : "grid",
|
58
|
+
"Mode" : "meter",
|
59
|
+
"P_Akku" : null,
|
60
|
+
"P_Grid" : 335.26931762695312,
|
61
|
+
"P_Load" : -335.26931762695312,
|
62
|
+
"P_PV" : null,
|
63
|
+
"rel_Autonomy" : 0,
|
64
|
+
"rel_SelfConsumption" : null
|
65
|
+
},
|
66
|
+
"Version" : "12"
|
67
|
+
}
|
68
|
+
},
|
69
|
+
"Head" : {
|
70
|
+
"RequestArguments" : {},
|
71
|
+
"Status" : {
|
72
|
+
"Code" : 0,
|
73
|
+
"Reason" : "",
|
74
|
+
"UserMessage" : ""
|
75
|
+
},
|
76
|
+
"Timestamp" : "2023-07-30T22:16:42+10:00"
|
77
|
+
}
|
78
|
+
}
|
79
|
+
recorded_at: Sun, 30 Jul 2023 12:16:42 GMT
|
80
|
+
- request:
|
81
|
+
method: get
|
82
|
+
uri: http://192.168.86.26/solar_api/v1/GetMeterRealtimeData.cgi?Scope=System
|
83
|
+
body:
|
84
|
+
encoding: US-ASCII
|
85
|
+
string: ''
|
86
|
+
headers:
|
87
|
+
User-Agent:
|
88
|
+
- sunnycarcharger-agent
|
89
|
+
response:
|
90
|
+
status:
|
91
|
+
code: 200
|
92
|
+
message: OK
|
93
|
+
headers:
|
94
|
+
content-type:
|
95
|
+
- application/json
|
96
|
+
cache-control:
|
97
|
+
- no-cache, no-store, must-revalidate
|
98
|
+
pragma:
|
99
|
+
- no-cache
|
100
|
+
expires:
|
101
|
+
- '0'
|
102
|
+
content-length:
|
103
|
+
- '2705'
|
104
|
+
date:
|
105
|
+
- Sun, 30 Jul 2023 12:16:43 GMT
|
106
|
+
server:
|
107
|
+
- webserver
|
108
|
+
body:
|
109
|
+
encoding: UTF-8
|
110
|
+
string: |
|
111
|
+
{
|
112
|
+
"Body" : {
|
113
|
+
"Data" : {
|
114
|
+
"0" : {
|
115
|
+
"Current_AC_Phase_1" : 0.18578459322452545,
|
116
|
+
"Current_AC_Phase_2" : 2.0522370338439941,
|
117
|
+
"Current_AC_Phase_3" : 0,
|
118
|
+
"Current_AC_Sum" : 2.2380216270685196,
|
119
|
+
"Details" : {
|
120
|
+
"Manufacturer" : "Fronius",
|
121
|
+
"Model" : "CCS WattNode WND-3D-480-MB",
|
122
|
+
"Serial" : "745995"
|
123
|
+
},
|
124
|
+
"Enable" : 1,
|
125
|
+
"EnergyReal_WAC_Minus_Absolute" : 49028617,
|
126
|
+
"EnergyReal_WAC_Phase_1_Consumed" : 5359053,
|
127
|
+
"EnergyReal_WAC_Phase_1_Produced" : 30984743,
|
128
|
+
"EnergyReal_WAC_Phase_2_Consumed" : 18531328,
|
129
|
+
"EnergyReal_WAC_Phase_2_Produced" : 21950501,
|
130
|
+
"EnergyReal_WAC_Phase_3_Consumed" : 0,
|
131
|
+
"EnergyReal_WAC_Phase_3_Produced" : 0,
|
132
|
+
"EnergyReal_WAC_Plus_Absolute" : 19983755,
|
133
|
+
"EnergyReal_WAC_Sum_Consumed" : 19983755,
|
134
|
+
"EnergyReal_WAC_Sum_Produced" : 49028617,
|
135
|
+
"Frequency_Phase_Average" : 50.03289794921875,
|
136
|
+
"Meter_Location_Current" : 0,
|
137
|
+
"PowerApparent_S_Phase_1" : 43.604618072509766,
|
138
|
+
"PowerApparent_S_Phase_2" : 497.7763671875,
|
139
|
+
"PowerApparent_S_Phase_3" : 0,
|
140
|
+
"PowerApparent_S_Sum" : 541.3809814453125,
|
141
|
+
"PowerFactor_Phase_1" : 0.76950681209564209,
|
142
|
+
"PowerFactor_Phase_2" : 0.61130160093307495,
|
143
|
+
"PowerFactor_Phase_3" : 1,
|
144
|
+
"PowerFactor_Sum" : 0.62404400110244751,
|
145
|
+
"PowerReactive_Q_Phase_1" : -14.466190338134766,
|
146
|
+
"PowerReactive_Q_Phase_2" : -348.84356689453125,
|
147
|
+
"PowerReactive_Q_Phase_3" : 0,
|
148
|
+
"PowerReactive_Q_Sum" : -363.30975341796875,
|
149
|
+
"PowerReal_P_Phase_1" : 33.554050445556641,
|
150
|
+
"PowerReal_P_Phase_2" : 304.29147338867188,
|
151
|
+
"PowerReal_P_Phase_3" : 0,
|
152
|
+
"PowerReal_P_Sum" : 337.84555053710938,
|
153
|
+
"TimeStamp" : 1690719403,
|
154
|
+
"Visible" : 1,
|
155
|
+
"Voltage_AC_PhaseToPhase_12" : 414.82183837890625,
|
156
|
+
"Voltage_AC_PhaseToPhase_23" : 241.61917114257812,
|
157
|
+
"Voltage_AC_PhaseToPhase_31" : 233.82379150390625,
|
158
|
+
"Voltage_AC_Phase_1" : 234.70613098144531,
|
159
|
+
"Voltage_AC_Phase_2" : 242.55319213867188,
|
160
|
+
"Voltage_AC_Phase_3" : 0,
|
161
|
+
"Voltage_AC_Phase_Average" : 238.62966918945312
|
162
|
+
}
|
163
|
+
}
|
164
|
+
},
|
165
|
+
"Head" : {
|
166
|
+
"RequestArguments" : {
|
167
|
+
"DeviceClass" : "Meter",
|
168
|
+
"Scope" : "System"
|
169
|
+
},
|
170
|
+
"Status" : {
|
171
|
+
"Code" : 0,
|
172
|
+
"Reason" : "",
|
173
|
+
"UserMessage" : ""
|
174
|
+
},
|
175
|
+
"Timestamp" : "2023-07-30T22:16:43+10:00"
|
176
|
+
}
|
177
|
+
}
|
178
|
+
recorded_at: Sun, 30 Jul 2023 12:16:44 GMT
|
179
|
+
recorded_with: VCR 6.2.0
|
@@ -13,6 +13,24 @@ describe Sunnycarcharger::Agent::Fronius do
|
|
13
13
|
assert_equal(3599, data.power_to_grid.to_i)
|
14
14
|
assert_equal(6444, data.power_from_solar.to_i)
|
15
15
|
assert_equal(2844, data.power_to_load.to_i)
|
16
|
+
assert_equal(38601, data.solar_energy_today.to_i)
|
17
|
+
assert data.energy_consumed
|
18
|
+
assert data.energy_produced
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it "fetches from fronius at night" do
|
23
|
+
fronius_ip = "192.168.86.26"
|
24
|
+
agent = Sunnycarcharger::Agent::Fronius.new(ip: fronius_ip)
|
25
|
+
VCR.use_cassette("fronius-night") do
|
26
|
+
data = agent.fetch
|
27
|
+
|
28
|
+
assert_equal(335, data.power_from_grid.to_i)
|
29
|
+
assert_equal(0, data.power_from_solar.to_i)
|
30
|
+
assert_equal(335, data.power_to_load.to_i)
|
31
|
+
assert_equal(62134, data.solar_energy_today.to_i)
|
32
|
+
assert data.energy_consumed
|
33
|
+
assert data.energy_produced
|
16
34
|
end
|
17
35
|
end
|
18
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunnycarcharger-agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dr Nic Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: anyway_config
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- lib/sunnycarcharger/agent/version.rb
|
104
104
|
- lib/sunnycarcharger/agent/web.rb
|
105
105
|
- test/fixtures/vcr_cassettes/fronius-midday.yml
|
106
|
+
- test/fixtures/vcr_cassettes/fronius-night.yml
|
106
107
|
- test/sunnycarcharger/agent/fronius_test.rb
|
107
108
|
- test/test_helper.rb
|
108
109
|
homepage: https://sunnycarcharger.com
|