sunnycarcharger-agent 1.0.2 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/exe/sunnycarcharger-agent +7 -3
- data/lib/sunnycarcharger/agent/config.rb +11 -0
- data/lib/sunnycarcharger/agent/fronius.rb +47 -19
- data/lib/sunnycarcharger/agent/invertor_data.rb +6 -1
- 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 +21 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e597967d1cfd8c1ee46871b7a305827914023f8beeb15e79b3a6aaf1b0682d1b
|
4
|
+
data.tar.gz: d59ea067d905fc3f28b5c25f330bf91351bd41574fd8eb8b3030799417633fb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71a65178b4a571925bed92ef6b3cc4b59a9804ae3e9dde69def469183a666c23535e417e6f33da634c33f817e1502199bc22089b1c0db3bd2aed0bc045dc56d8
|
7
|
+
data.tar.gz: 1b2a926d280593da53996986ed39d8e32c9b6a99393560321b9a1c3044b1990262afb016e31c5850b0382cbbb4929a70e173ec4d5dc1dbb72fd27a5a8b842a41
|
data/README.md
CHANGED
@@ -20,9 +20,13 @@ gem install sunnycarcharger-agent
|
|
20
20
|
## Usage
|
21
21
|
|
22
22
|
```plain
|
23
|
-
FRONIUS_IP=192.168.1.2 WEB_TOKEN=<token from sunnycarcharger.com> sunnycarcharger-agent
|
23
|
+
FRONIUS_IP=192.168.1.2:5757 WEB_TOKEN=<token from sunnycarcharger.com> sunnycarcharger-agent
|
24
|
+
# or
|
25
|
+
FRONIUS_IPS=192.168.1.2:5757,192.168.1.3:5757 WEB_TOKEN=<token from sunnycarcharger.com> sunnycarcharger-agent
|
24
26
|
```
|
25
27
|
|
28
|
+
Use either `$FRONIUS_IPS` or `$FRONIUS_IP` to provide a comma separated list of IP address that the Fronius inverter might be available on. Include the `:port` if its not the default port of `80`.
|
29
|
+
|
26
30
|
## License
|
27
31
|
|
28
32
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/exe/sunnycarcharger-agent
CHANGED
@@ -2,14 +2,16 @@
|
|
2
2
|
|
3
3
|
require "sunnycarcharger/agent"
|
4
4
|
|
5
|
-
puts "Fronius IP
|
5
|
+
puts "Fronius IP addresses: #{Config.fronius_ips.join(", ")}"
|
6
6
|
puts "Web URL: #{Config.web_url}"
|
7
7
|
|
8
8
|
startup_errors = false
|
9
9
|
|
10
10
|
fronius_client = Sunnycarcharger::Agent::Fronius.new
|
11
11
|
unless fronius_client.connected?
|
12
|
-
|
12
|
+
Config.fronius_ips.each do |ip|
|
13
|
+
warn "ERROR: Fronius #{ip} could not be connected"
|
14
|
+
end
|
13
15
|
startup_errors = true
|
14
16
|
end
|
15
17
|
web_client = Sunnycarcharger::Agent::Web.new
|
@@ -24,7 +26,9 @@ loop do
|
|
24
26
|
begin
|
25
27
|
invertor_data = fronius_client.fetch
|
26
28
|
rescue Faraday::ConnectionFailed, Errno::ECONNREFUSED
|
27
|
-
|
29
|
+
Config.fronius_ips.each do |ip|
|
30
|
+
warn "ERROR: Fronius #{ip} could not be connected"
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
begin
|
@@ -8,12 +8,23 @@ class AgentConfig < Anyway::Config
|
|
8
8
|
attr_config refresh_interval: 1 # minutes
|
9
9
|
|
10
10
|
attr_config :fronius_ip
|
11
|
+
attr_config fronius_ips: []
|
11
12
|
|
12
13
|
extend_options do |parser, config|
|
13
14
|
parser.on_tail "-h", "--help" do
|
14
15
|
puts parser
|
15
16
|
end
|
16
17
|
end
|
18
|
+
|
19
|
+
on_load do
|
20
|
+
if fronius_ip
|
21
|
+
if fronius_ip.is_a?(Array)
|
22
|
+
self.fronius_ips = fronius_ip
|
23
|
+
elsif fronius_ip.is_a?(String)
|
24
|
+
self.fronius_ips = [fronius_ip]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
17
28
|
end
|
18
29
|
|
19
30
|
Config = AgentConfig.new
|
@@ -1,36 +1,64 @@
|
|
1
1
|
require "faraday"
|
2
2
|
|
3
3
|
class Sunnycarcharger::Agent::Fronius
|
4
|
-
def initialize(
|
5
|
-
raise ArgumentError, "Missing Fronius IP
|
6
|
-
@
|
4
|
+
def initialize(ips: Config.fronius_ips)
|
5
|
+
raise ArgumentError, "Missing Fronius IP addresses" unless ips
|
6
|
+
@ips = ips
|
7
7
|
end
|
8
8
|
|
9
9
|
def client
|
10
|
-
@client ||=
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
10
|
+
@client ||= begin
|
11
|
+
successful_client = nil
|
12
|
+
@ips.find do |ip|
|
13
|
+
successful_client = Faraday.new(
|
14
|
+
"http://" + ip,
|
15
|
+
headers: {"User-Agent" => "sunnycarcharger-agent"}
|
16
|
+
) do |conn|
|
17
|
+
conn.request :json
|
18
|
+
conn.response :json
|
19
|
+
conn.response :raise_error
|
20
|
+
# conn.request :retry, retry_options if retry_options # Must be registered after :raise_error
|
21
|
+
conn.adapter Faraday.default_adapter
|
22
|
+
conn.options.timeout = 3
|
23
|
+
end
|
24
|
+
true
|
25
|
+
rescue Faraday::ConnectionFailed, Errno::ECONNREFUSED
|
26
|
+
false
|
27
|
+
end
|
28
|
+
successful_client || raise("Could not connect to any of the provided Fronius IP addresses")
|
20
29
|
end
|
21
30
|
end
|
22
31
|
|
23
32
|
def fetch
|
24
|
-
path = "/solar_api/v1/GetPowerFlowRealtimeData.fcgi"
|
25
|
-
response = client.get(path).body
|
26
33
|
data = Sunnycarcharger::Agent::InvertorData.new
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
data.
|
34
|
+
|
35
|
+
response = client.get("/solar_api/v1/GetPowerFlowRealtimeData.fcgi").body
|
36
|
+
body = response.dig("Body", "Data", "Site")
|
37
|
+
data.power_from_grid = body.dig("P_Grid").to_i
|
38
|
+
data.power_to_load = -1 * body.dig("P_Load").to_i
|
39
|
+
data.power_from_solar = body.dig("P_PV").to_i
|
40
|
+
data.solar_energy_today = body.dig("E_Day").to_i
|
41
|
+
|
42
|
+
begin
|
43
|
+
response = client.get("/solar_api/v1/GetMeterRealtimeData.cgi?Scope=System").body
|
44
|
+
body = response.dig("Body", "Data", "0")
|
45
|
+
data.energy_consumed = body.dig("EnergyReal_WAC_Sum_Consumed").to_i
|
46
|
+
data.energy_produced = body.dig("EnergyReal_WAC_Sum_Produced").to_i
|
47
|
+
data.serial = body.dig("Details", "Serial")
|
48
|
+
rescue => e
|
49
|
+
puts "Error fetching energy_consumed and energy_produced: #{e}"
|
50
|
+
end
|
51
|
+
|
31
52
|
data
|
32
53
|
end
|
33
54
|
|
55
|
+
# {"Manufacturer"=>"Fronius", "Model"=>"CCS WattNode WND-3D-480-MB", "Serial"=>"123456"}
|
56
|
+
def inverter_details
|
57
|
+
response = client.get("/solar_api/v1/GetMeterRealtimeData.cgi?Scope=System").body
|
58
|
+
body = response.dig("Body", "Data", "0")
|
59
|
+
body.dig("Details")
|
60
|
+
end
|
61
|
+
|
34
62
|
def connected?
|
35
63
|
fetch
|
36
64
|
true
|
@@ -1,5 +1,7 @@
|
|
1
1
|
class Sunnycarcharger::Agent::InvertorData
|
2
|
+
attr_accessor :serial
|
2
3
|
attr_accessor :power_from_grid, :power_to_load, :power_from_solar, :solar_energy_today
|
4
|
+
attr_accessor :energy_consumed, :energy_produced
|
3
5
|
|
4
6
|
def power_to_grid
|
5
7
|
-power_from_grid
|
@@ -7,10 +9,13 @@ class Sunnycarcharger::Agent::InvertorData
|
|
7
9
|
|
8
10
|
def as_json
|
9
11
|
{
|
12
|
+
serial: serial,
|
10
13
|
power_from_grid: power_from_grid,
|
11
14
|
power_to_load: power_to_load,
|
12
15
|
power_from_solar: power_from_solar,
|
13
|
-
solar_energy_today: solar_energy_today
|
16
|
+
solar_energy_today: solar_energy_today,
|
17
|
+
energy_consumed: energy_consumed,
|
18
|
+
energy_produced: energy_produced
|
14
19
|
}
|
15
20
|
end
|
16
21
|
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
|
@@ -4,8 +4,8 @@ require "test_helper"
|
|
4
4
|
|
5
5
|
describe Sunnycarcharger::Agent::Fronius do
|
6
6
|
it "fetches from fronius" do
|
7
|
-
|
8
|
-
agent = Sunnycarcharger::Agent::Fronius.new(
|
7
|
+
fronius_ips = ["192.168.86.26"]
|
8
|
+
agent = Sunnycarcharger::Agent::Fronius.new(ips: fronius_ips)
|
9
9
|
VCR.use_cassette("fronius-midday") do
|
10
10
|
data = agent.fetch
|
11
11
|
|
@@ -14,6 +14,25 @@ describe Sunnycarcharger::Agent::Fronius do
|
|
14
14
|
assert_equal(6444, data.power_from_solar.to_i)
|
15
15
|
assert_equal(2844, data.power_to_load.to_i)
|
16
16
|
assert_equal(38601, data.solar_energy_today.to_i)
|
17
|
+
assert_equal("745995", data.serial)
|
18
|
+
assert data.energy_consumed
|
19
|
+
assert data.energy_produced
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "fetches from fronius at night" do
|
24
|
+
fronius_ips = ["192.168.86.26"]
|
25
|
+
agent = Sunnycarcharger::Agent::Fronius.new(ips: fronius_ips)
|
26
|
+
VCR.use_cassette("fronius-night") do
|
27
|
+
data = agent.fetch
|
28
|
+
|
29
|
+
assert_equal(335, data.power_from_grid.to_i)
|
30
|
+
assert_equal(0, data.power_from_solar.to_i)
|
31
|
+
assert_equal(335, data.power_to_load.to_i)
|
32
|
+
assert_equal(62134, data.solar_energy_today.to_i)
|
33
|
+
assert_equal("745995", data.serial)
|
34
|
+
assert data.energy_consumed
|
35
|
+
assert data.energy_produced
|
17
36
|
end
|
18
37
|
end
|
19
38
|
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.
|
4
|
+
version: 1.1.1
|
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-
|
11
|
+
date: 2023-10-28 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
|
@@ -128,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
129
|
- !ruby/object:Gem::Version
|
129
130
|
version: '0'
|
130
131
|
requirements: []
|
131
|
-
rubygems_version: 3.4.
|
132
|
+
rubygems_version: 3.4.20
|
132
133
|
signing_key:
|
133
134
|
specification_version: 4
|
134
135
|
summary: Run agent within home network to get solar invertor data and upload to Sunny
|