wh2600 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/wh2600.rb +55 -2
  3. metadata +17 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8787c94fe3f598788b75f9a2643dac4aae517ba1
4
- data.tar.gz: e2ca625d3c2ce03159e13f8a4ed5150adc2b0d6f
3
+ metadata.gz: b031dbcd6b4ac91658daddc4910bcb7bb849ce94
4
+ data.tar.gz: a6e3d39533e6dad934fe8a350a46ae05d21d9e8a
5
5
  SHA512:
6
- metadata.gz: 07be3a22f6b439d4fa5da669e59af84b369dd02de906928aebaa3afc7ffab8f311bbe4d42fc8f4161e71bdb265c63ac54bdf2355f76e6a495ecf4494969f6178
7
- data.tar.gz: 686617b0ab061115b198cada3d75c7d10386caa26801b1f754a22f2c32783e925851d8347fef2b32aa79c31466b2b9c2cf04fc76f692f8c4199f52cfca010ee3
6
+ metadata.gz: 700395c59ab06f94b43762a46575f7650f1c36b13777aa9834b88a347179c50c108b636afc716141f99c85e8e8988ac2bbcfdf3794c339bdcb4f0ab7068eb3da
7
+ data.tar.gz: 262280616223ff54f9ceace5d222f739d992f0315ccd61dd68659377e9028d4669bc5d988ec8376b1128ff27bf275a9994dbf364801adbe86150a6d61ed2b68d
@@ -1,5 +1,58 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+
1
4
  class Wh2600
2
- def self.hi
3
- puts 'hello'
5
+ def initialize(ip_address)
6
+ @ip_address = ip_address
7
+ end
8
+
9
+ def get_data(live_data_uri='livedata.htm')
10
+ data = {}
11
+ data_html = Nokogiri::HTML(open_page(live_data_uri))
12
+ data['receiver_datetime'] = DateTime.strptime(data_html.at_xpath('//input[@name="CurrTime"]')['value'], '%H:%M %m/%d/%Y')
13
+ data['sensors'] = {}
14
+ data['sensors']['indoor_id'] = data_html.at_xpath('//input[@name="IndoorID"]').attr('value')
15
+ data['sensors']['outdoor1_id'] = data_html.at_xpath('//input[@name="Outdoor1ID"]').attr('value')
16
+ data['sensors']['outdoor2_id'] = data_html.at_xpath('//input[@name="Outdoor2ID"]').attr('value')
17
+ data['temperature'] = {}
18
+ data['humidity'] = {}
19
+ data['temperature']['in'] = data_html.at_xpath('//input[@name="inTemp"]').attr('value').to_f
20
+ data['temperature']['out'] = data_html.at_xpath('//input[@name="outTemp"]').attr('value').to_f
21
+ data['humidity']['in'] = data_html.at_xpath('//input[@name="inHumi"]').attr('value').to_i
22
+ data['humidity']['out'] = data_html.at_xpath('//input[@name="outHumi"]').attr('value').to_i
23
+ data['pressure'] = {}
24
+ data['pressure']['absolute'] = data_html.at_xpath('//input[@name="AbsPress"]').attr('value').to_f
25
+ data['pressure']['relative'] = data_html.at_xpath('//input[@name="RelPress"]').attr('value').to_f
26
+ data['wind'] = {}
27
+ data['wind']['direction'] = data_html.at_xpath('//input[@name="windir"]').attr('value').to_i
28
+ data['wind']['speed'] = data_html.at_xpath('//input[@name="avgwind"]').attr('value').to_f
29
+ data['wind']['gust'] = data_html.at_xpath('//input[@name="gustspeed"]').attr('value').to_f
30
+ data['solar'] = {}
31
+ data['solar']['radiation'] = data_html.at_xpath('//input[@name="solarrad"]').attr('value').to_f
32
+ data['solar']['uv'] = data_html.at_xpath('//input[@name="uv"]').attr('value').to_f
33
+ data['solar']['uvi'] = data_html.at_xpath('//input[@name="uvi"]').attr('value').to_f
34
+ data['rain'] = {}
35
+ data['rain']['hourly'] = data_html.at_xpath('//input[@name="rainofhourly"]').attr('value').to_f
36
+ data['rain']['daily'] = data_html.at_xpath('//input[@name="rainofhourly"]').attr('value').to_f
37
+ data['rain']['weekly'] = data_html.at_xpath('//input[@name="rainofhourly"]').attr('value').to_f
38
+ data['rain']['monthly'] = data_html.at_xpath('//input[@name="rainofhourly"]').attr('value').to_f
39
+ data['rain']['yearly'] = data_html.at_xpath('//input[@name="rainofhourly"]').attr('value').to_f
40
+ return data
41
+ end
42
+
43
+ def get_units(units_uri='station.htm')
44
+ units = {}
45
+ units_html = Nokogiri::HTML(open_page(units_uri))
46
+ units['temperature'] = units_html.at_xpath('//select[@name="u_Temperature"]/option[@selected]/text()').to_s
47
+ units['pressure'] = units_html.at_xpath('//select[@name="unit_Pressure"]/option[@selected]/text()').to_s
48
+ units['rainfall'] = units_html.at_xpath('//select[@name="u_Rainfall"]/option[@selected]/text()').to_s
49
+ units['wind'] = units_html.at_xpath('//select[@name="unit_Wind"]/option[@selected]/text()').to_s
50
+ units['solar_radiation'] = units_html.at_xpath('//select[@name="unit_Solar"]/option[@selected]/text()').to_s
51
+ return units
52
+ end
53
+
54
+ private
55
+ def open_page(page)
56
+ open("http://#{@ip_address}/#{page}")
4
57
  end
5
58
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wh2600
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krunoslav Husak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-16 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2016-01-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
13
27
  description: Ruby gem for retrieving live data from Conrad Renkforce WH2600 / FOSHK
14
28
  WH2600 / Froggit WH2601 / Ambient Weather WS-1400 weather station
15
29
  email: kruno@binel.hr