-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_state.rb
34 lines (28 loc) · 977 Bytes
/
update_state.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env ruby
require_relative('thermometer')
require_relative('functions')
require('open-uri')
puts "\n*** Initializing Setup ***"
puts "Time: #{Time.now}"
t=Thermometer.new
#puts "Endpoint details:"
#puts "host: #{command_line_arguments[:endpoint].host}"
#puts "path: #{command_line_arguments[:endpoint].path}"
#puts "port: #{command_line_arguments[:endpoint].port}"
#puts "user: #{command_line_arguments[:endpoint].user}"
#puts "pswd: #{command_line_arguments[:endpoint].password}"
puts "\n*** Finding Sensor ***"
t.find_sensor()
puts "\n*** Checking Thermometer File ***"
readings = t.read
readings.each do |reading|
puts "Reading in celcius: "+reading.to_celcius.to_s
puts "Reading in fahrenheit: "+reading.to_fahrenheit.to_s
end
puts "\n*** Recording Temperature to Endpoint ***"
readings.each do |reading|
puts "updating state of pool"
fahrenheit = reading.to_fahrenheit
puts "temperature recorded: #{fahrenheit}"
update_state(fahrenheit)
end