summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scarecrow.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/scarecrow.rb b/scarecrow.rb
index a4a057b..ef3b694 100644
--- a/scarecrow.rb
+++ b/scarecrow.rb
@@ -4,6 +4,25 @@ require 'mqtt'
set :public_folder, File.dirname(__FILE__) + '/public'
set :bind, '::'
+def init
+ Thread.new do
+ MQTT::Client.connect('192.168.0.16') do |c|
+ c.get('humidity') do |topic,message|
+ puts "#{topic}: #{message}"
+ end
+ end
+ end
+ Thread.new do
+ MQTT::Client.connect('192.168.0.16') do |c|
+ c.get('temperature') do |topic,message|
+ puts "#{topic}: #{message}"
+ end
+ end
+ end
+end
+
get '/' do
send_file File.join(settings.public_folder, 'index.html')
end
+
+init