Add dashboard

This commit is contained in:
2022-09-20 00:27:25 +01:00
parent bdfe02f776
commit e689c852e7
96 changed files with 16313 additions and 1 deletions

21
jobs/quote.rb Normal file
View File

@@ -0,0 +1,21 @@
require 'net/http'
require 'uri'
require 'json'
server = "http://api.forismatic.com"
SCHEDULER.every '3h', :first_in => 0 do |job|
url = URI.parse("#{server}/api/1.0/?method=getQuote&key=&format=json&lang=en")
req = Net::HTTP::Get.new(url.to_s)
res = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)
}
# Convert to JSON
j = JSON[res.body]
# Update the dashboard
send_event("quote", { text: j['quoteText'], moreinfo: j['quoteAuthor'] })
end