saj_collector 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a31fd70ac0c6bd669a29b37ae6f1b0193b6dd45164d08d93a6d7277edd709925
4
- data.tar.gz: de1f11c67a24f03786dcee7c3fe3072908201c0ec49b4eb6cc824ea63cdea9fc
3
+ metadata.gz: 370630fb07fea199502ce6a8a421ce7d0e4a8253fec109baac95597ed8d0e225
4
+ data.tar.gz: 319651b7846f4ece02d5d8d725873291cf490d3a20e3dbfbb9e6775f622f9ea7
5
5
  SHA512:
6
- metadata.gz: f74bdb009a76448a045064a7775c08fe892bbd6f22afd4813f3969b3eee1b3ece82ca49af61f67ac8c0657b0c82e003439c4d55bcde8590435853e58612e050a
7
- data.tar.gz: 3dd6a464507c90befac9a0ea9f2c50344f919772522f80fe5d4977a098ea4226e2397f07de788ebacb42f2640f0f60dc39832c04180a57de8c568303ace44ea2
6
+ metadata.gz: 9c27ed515b65a42606a847f52edd54e35df6d794f53d999e3f24219599bc766b6932e2f226a4efc6db1c0b4c8f2891e2f68b04952bd33305937ea2e00d7eb7a6
7
+ data.tar.gz: 814743887fe0821186275a9ac7bc6a15650db9d4dddeb5166c1c7acccbe3f06e3e4a8bb32a47b0d90b0f8d8680b6fda5e52ff7bdacb4c9badde1912ff20c7a33
data/README.md CHANGED
@@ -24,7 +24,6 @@ system id and API key can be found on your
24
24
  [PVOutput account page](https://pvoutput.org/account.jsp).
25
25
 
26
26
  ``` yaml
27
- ---
28
27
  :saj: a.b.c.d
29
28
  :system_id: 123456
30
29
  :api_key: fb6a2e3
data/exe/saj_collector CHANGED
@@ -4,6 +4,7 @@ require 'rexml/document'
4
4
  require 'net/http'
5
5
  require 'pvoutput/client'
6
6
  require 'yaml'
7
+ require 'ipaddress'
7
8
 
8
9
  # Load the configuration from the yaml file
9
10
  sajcollector_config = YAML.load_file('saj_collector.yaml')
@@ -12,6 +13,13 @@ sajcollector_config = YAML.load_file('saj_collector.yaml')
12
13
  # can be obtained from the pvoutput website
13
14
  pvoutput = PVOutput::Client.new(sajcollector_config[:system_id], sajcollector_config[:api_key])
14
15
 
16
+ unless IPAddress.valid?(sajcollector_config[:saj])
17
+ raise ("[#{sajcollector_config[:saj]}] is not a valid IP address")
18
+ end
19
+
20
+ # Get the current realtime data from the SAJ device
21
+ c = Net::HTTP.get(sajcollector_config[:saj], '/real_time_data.xml')
22
+
15
23
  options = {
16
24
  'temperature' => 0, # Temperature in celcius
17
25
  'energy_generated' => 0, # Energy generation in watt hours
@@ -24,9 +32,6 @@ options = {
24
32
  'runtime_all_time' => 0
25
33
  }
26
34
 
27
- # Get the current realtime data from the SAJ device
28
- c = Net::HTTP.get(sajcollector_config[:saj], '/real_time_data.xml')
29
-
30
35
  # Let REXML parse the XML site
31
36
  doc = REXML::Document.new c
32
37
 
@@ -4,6 +4,7 @@ require 'rexml/document'
4
4
  require 'net/http'
5
5
  require 'pvoutput/client'
6
6
  require 'yaml'
7
+ require 'ipaddress'
7
8
 
8
9
  # Load the configuration from the yaml file
9
10
  sajcollector_config = YAML.load_file('saj_collector.yaml')
@@ -12,6 +13,10 @@ sajcollector_config = YAML.load_file('saj_collector.yaml')
12
13
  # can be obtained from the pvoutput website
13
14
  pvoutput = PVOutput::Client.new(sajcollector_config[:system_id], sajcollector_config[:api_key])
14
15
 
16
+ unless IPAddress.valid?(sajcollector_config[:saj])
17
+ raise ("[#{sajcollector_config[:saj]}] is not a valid IP address")
18
+ end
19
+
15
20
  # Get the current day trend data from the SAJ device
16
21
  c = Net::HTTP.get(sajcollector_config[:saj], '/day_trend.xml')
17
22
 
@@ -1,3 +1,3 @@
1
1
  module SAJCollector
2
- VERSION = '0.5.5'.freeze
2
+ VERSION = '0.5.6'.freeze
3
3
  end
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
 
20
20
  spec.add_dependency 'pvoutput', '~> 0.4.0'
21
+ spec.add_dependency 'ipaddress'
21
22
 
22
23
  spec.add_development_dependency 'bundler'
23
24
  spec.add_development_dependency 'rake', '~> 10.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saj_collector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johnny Willemsen
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.4.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: ipaddress
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement