Added lua function to get the current hostname

This makes it possible to set options depending on what machine we are
running
This commit is contained in:
2024-05-03 19:37:16 +02:00
parent bb15558ab2
commit bf3d757710
4 changed files with 58 additions and 8 deletions

View File

@@ -1,8 +1,7 @@
print("Hello from lua")
automation.fulfillment = {
openid_url = "https://login.huizinga.dev/api/oidc",
}
local host = automation.util.get_hostname()
print("Running @" .. host)
local debug, value = pcall(automation.util.get_env, "DEBUG")
if debug and value ~= "true" then
@@ -17,13 +16,19 @@ local function mqtt_automation(topic)
return "automation/" .. topic
end
automation.fulfillment = {
openid_url = "https://login.huizinga.dev/api/oidc",
}
local mqtt_client = automation.new_mqtt_client({
host = debug and "olympus.lan.huizinga.dev" or "mosquitto",
host = (host == "zeus" and "olympus.lan.huizinga.dev")
or (host == "hephaestus" and "olympus.vpn.huizinga.dev")
or "mosquitto",
port = 8883,
client_name = debug and "automation-debug" or "automation_rs",
client_name = "automation-" .. host,
username = "mqtt",
password = automation.util.get_env("MQTT_PASSWORD"),
tls = debug and true or false,
tls = host == "zeus" or host == "hephaestus",
})
automation.device_manager:add(Ntfy.new({