docs » CameraStatus

Trigger webhooks to enable or disable a status light/monitor/etc. based on the computer's camera state.

Example (assumes you are using SpoonInstall to load spoons):

-- This plugin requires two webhook URLs (e.g. from HomeAssistant) that will
-- be triggered based on the computer's camera state.

local statusONwebhook = "https://some-webhook.url/on"
local statusOFFwebhook = "https://some-webhook.url/off"

hs.loadSpoon("SpoonInstall")
SpoonInstall = spoon.SpoonInstall
SpoonInstall.repos = {
    default = {
        url = "https://github.com/Hammerspoon/Spoons",
        desc = "Main Hammerspoon Spoon repository",
        branch = "master",
    },
    jamescurtin = {
        url = "https://github.com/jamescurtin/Spoons",
        desc = "James Curtin's Spoons",
        branch = "master",
    },
}

SpoonInstaller:andUse("CameraStatus",
  {
      repo = "jamescurtin",
      start = true,
      config = {
          cameraOnHook = statusONwebhook,
          cameraOffHook = statusOFFwebhook,
      }
  }
)

API Overview

API Documentation

Variables

cameraOffHook
Signature CameraStatus.cameraOffHook (String)
Type Variable
Description

A webhook URL that will be used to trigger an event when an attached camera is turned off.

Source Source/CameraStatus.spoon/init.lua line 65
cameraOnHook
Signature CameraStatus.cameraOnHook (String)
Type Variable
Description

A webhook URL that will be used to trigger an event when an attached camera is turned on.

Source Source/CameraStatus.spoon/init.lua line 60

Methods

checkCameraStatus
Signature CameraStatus:checkCameraStatus() -> Self
Type Method
Description

Makes a one-time call to check camera state.

Parameters
  • None
Returns
  • Self
Notes

Makes an empty POST request to the "cameraOnHook" webhook if any camera is enabled. Makes an empty POST request to the "cameraOffHook" webhook if no camera is enabled.

Source Source/CameraStatus.spoon/init.lua line 93
start
Signature CameraStatus:start() -> Self
Type Method
Description

Enables the CameraStatus spoon.

Parameters
  • None
Returns
  • Self
Notes

The spoon uses a camera watcher to poll for camera status. Additionally, it will register cameras that are added after the spoon has been initialized. Calls the "On" webhook if any camera is enabled. Calls the "Off" webhook if no camera is enabled.

Source Source/CameraStatus.spoon/init.lua line 123