dump.lua
#!/usr/bin/env lua
package.path = "./src/?/init.lua;./src/?.lua;./?/init.lua;"..package.path
require "logging"
local Hue = require "philips-hue"
local copas = require "copas"
local Timer = require "copas.timer"
local hue = Hue.new {
apikey = os.getenv("HUE_KEY"),
address = os.getenv("HUE_IP"),
callback = function(hue, event_data)
if event_data.type == "status" then
print("------------------ Hue client status is now: ", event_data.event)
elseif event_data.type == "hue" then
if event_data.event == "update" then
print("Changes received for resource "..event_data.current.id..": ", require("pl.pretty").write(event_data.received))
end
else
print("Received an unknown event type, expected either 'hue' or 'status', got: "..tostring(event_data.type))
end
end,
}
copas(function()
hue:start()
Timer.new { delay = 5 * 60,
callback = function() hue:stop() end
}
end)