diff --git a/config.lua b/config.lua index f3cdc5b..cafbcf7 100644 --- a/config.lua +++ b/config.lua @@ -2,17 +2,21 @@ local devices = require("automation:devices") local device_manager = require("automation:device_manager") local utils = require("automation:utils") local secrets = require("automation:secrets") -local debug = require("automation:variables").debug or false +local debug = require("automation:variables").debug and true or false print(_VERSION) local host = utils.get_hostname() print("Running @" .. host) +--- @param topic string +--- @return string local function mqtt_z2m(topic) return "zigbee2mqtt/" .. topic end +--- @param topic string +--- @return string local function mqtt_automation(topic) return "automation/" .. topic end diff --git a/definitions/automation:devices.lua b/definitions/automation:devices.lua new file mode 100644 index 0000000..1e8ec2c --- /dev/null +++ b/definitions/automation:devices.lua @@ -0,0 +1,33 @@ +---@meta + +local devices + +---@class Action +---@field action "broadcast" +---@field extras table | nil +---@field label string | nil +---@clear clear bool|nil + +---@class Notification +---@field title string +---@field message string | nil +-- NOTE: It might be possible to specify this down to the actual possible values +---@field tags string[] | nil +---@field priority "min" | "low" | "default" | "high" | "max" | nil +---@field actions Action[] | nil + +---@class Ntfy +local Ntfy +---@async +---@param notification Notification +function Ntfy:send_notification(notification) end + +---@class NtfyConfig +---@field topic string + +devices.Ntfy = {} +---@param config NtfyConfig +---@return Ntfy +function devices.Ntfy.new(config) end + +return devices diff --git a/definitions/automation:secrets.lua b/definitions/automation:secrets.lua new file mode 100644 index 0000000..6494943 --- /dev/null +++ b/definitions/automation:secrets.lua @@ -0,0 +1,6 @@ +---@meta + +---@type table +local secrets + +return secrets diff --git a/definitions/automation:utils.lua b/definitions/automation:utils.lua new file mode 100644 index 0000000..d8b380c --- /dev/null +++ b/definitions/automation:utils.lua @@ -0,0 +1,27 @@ +---@meta + +local utils + +---@class Timeout +local Timeout +---@async +---@param timeout number +---@param callback fun() +function Timeout:start(timeout, callback) end +---@async +function Timeout:cancel() end +---@async +---@return boolean +function Timeout:is_waiting() end + +utils.Timeout = {} +---@return Timeout +function utils.Timeout.new() end + +--- @return string hostname +function utils.get_hostname() end + +--- @return number epoch +function utils.get_epoch() end + +return utils diff --git a/definitions/automation:variables.lua b/definitions/automation:variables.lua new file mode 100644 index 0000000..6f09c6d --- /dev/null +++ b/definitions/automation:variables.lua @@ -0,0 +1,6 @@ +---@meta + +---@type table +local variables + +return variables