Skip to content

Commit

Permalink
Latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsj committed Jan 3, 2021
1 parent e30d527 commit e98d48e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
1 change: 1 addition & 0 deletions Spoons/Hue.spoon/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ function obj:doPoll()
-- FIXME: Handle error codes
if code == 200 then
local rawJSON = hs.json.decode(body)
print(hs.inspect(rawJSON))
if rawJSON["state"] then
self.sensorCallback(rawJSON["state"]["presence"], sensorID)
end
Expand Down
4 changes: 3 additions & 1 deletion hueMotionSensor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function hueBridge:init()
end

function hueBridge:start()
print("Starting hueMotionSensor polling")
if not self.userCallback then
print("ERROR: No userCallback has been set")
return self
Expand Down Expand Up @@ -173,6 +174,7 @@ function hueBridge:pollingStart()
end

function hueBridge:doPoll()
print("polling...")
if self.isPollingSensor then
return self
end
Expand All @@ -183,6 +185,7 @@ function hueBridge:doPoll()
-- FIXME: Handle error codes
if code == 200 then
rawJSON = hs.json.decode(body)
print("sensor: "..hs.inspect(rawJSON))
if rawJSON["state"] then
self.userCallback(rawJSON["state"]["presence"])
end
Expand All @@ -192,4 +195,3 @@ function hueBridge:doPoll()
end

return hueBridge

39 changes: 20 additions & 19 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ spoon.SpoonInstall.use_syncinstall = true
Install=spoon.SpoonInstall

-- Control brightness for all compatible displays, using the keyboard brightness keys
Install:andUse("AllBrightness", {start=true})
--Install:andUse("AllBrightness", {start=true})

-- Direct URLs automatically based on patterns
Install:andUse("URLDispatcher",
Expand All @@ -81,6 +81,7 @@ Install:andUse("Seal",
s.plugins.useractions.actions = {
["Red Hat Bugzilla"] = { url = "https://bugzilla.redhat.com/show_bug.cgi?id=${query}", icon="favicon", keyword="bz" },
["Red Hat Support"] = { url = "https://access.redhat.com/support/cases/#/case/${query}", icon="favicon", keyword="sup" },
["Red Hat Support Exception"] = { url = "https://tools.apps.cee.redhat.com/support-exceptions/id/${query}", icon="favicon", keyword="se" },
["Launchpad Bugs"] = { url = "https://launchpad.net/bugs/${query}", icon="favicon", keyword="lp" },
}
end,
Expand All @@ -105,24 +106,24 @@ if (hostname == "fuyo") then
statuslets = require("statuslets"):start()

-- If the Philips Hue Motion Sensor in my office detects movement, make sure my Mac's screens are awake
hs.loadSpoon("Hue")
hueTimer = nil
spoon.Hue.sensorCallback = function(presence, sensor)
day = tonumber(os.date("%w"))
if day > 5 or day < 1 then
print("Ignoring motion, it's the weekend")
return
end
hour = tonumber(os.date("%H"))
if hour < 9 or hour > 18 then
print("Ignoring motion, it's not working hours")
return
end
if presence then
print("Motion detected on sensor: " .. sensor .. ". Declaring user activity")
officeMotionActivityID = hs.caffeinate.declareUserActivity(officeMotionActivityID)
end
end
--hs.loadSpoon("Hue")
--hueTimer = nil
--spoon.Hue.sensorCallback = function(presence, sensor)
-- day = tonumber(os.date("%w"))
-- if day > 5 or day < 1 then
-- print("Ignoring motion, it's the weekend")
-- return
-- end
-- hour = tonumber(os.date("%H"))
-- if hour < 9 or hour > 18 then
-- print("Ignoring motion, it's not working hours")
-- return
-- end
-- if presence then
-- print("Motion detected on sensor: " .. sensor .. ". Declaring user activity")
-- officeMotionActivityID = hs.caffeinate.declareUserActivity(officeMotionActivityID)
-- end
--end
else
statuslets = nil

Expand Down

0 comments on commit e98d48e

Please sign in to comment.