mqtt client is now created in lua
This commit is contained in:
35
config.lua
35
config.lua
@@ -13,6 +13,15 @@ local function mqtt_automation(topic)
|
||||
return "automation/" .. topic
|
||||
end
|
||||
|
||||
local mqtt_client = automation.create_mqtt_client({
|
||||
host = debug and "olympus.lan.huizinga.dev" or "mosquitto",
|
||||
port = 8883,
|
||||
client_name = debug and "automation-debug" or "automation_rs",
|
||||
username = "mqtt",
|
||||
password = automation.util.get_env("MQTT_PASSWORD"),
|
||||
tls = debug and true or false,
|
||||
})
|
||||
|
||||
automation.device_manager:add(Ntfy.new({
|
||||
topic = automation.util.get_env("NTFY_TOPIC"),
|
||||
event_channel = automation.event_channel,
|
||||
@@ -20,14 +29,14 @@ automation.device_manager:add(Ntfy.new({
|
||||
|
||||
automation.device_manager:add(Presence.new({
|
||||
topic = "automation_dev/presence/+/#",
|
||||
client = automation.mqtt_client,
|
||||
client = mqtt_client,
|
||||
event_channel = automation.event_channel,
|
||||
}))
|
||||
|
||||
automation.device_manager:add(DebugBridge.new({
|
||||
identifier = "debug_bridge",
|
||||
topic = mqtt_automation("debug"),
|
||||
client = automation.mqtt_client,
|
||||
client = mqtt_client,
|
||||
}))
|
||||
|
||||
local hue_ip = "10.0.0.146"
|
||||
@@ -46,7 +55,7 @@ automation.device_manager:add(HueBridge.new({
|
||||
automation.device_manager:add(LightSensor.new({
|
||||
identifier = "living_light_sensor",
|
||||
topic = mqtt_z2m("living/light"),
|
||||
client = automation.mqtt_client,
|
||||
client = mqtt_client,
|
||||
min = 22000,
|
||||
max = 23500,
|
||||
event_channel = automation.event_channel,
|
||||
@@ -56,7 +65,7 @@ automation.device_manager:add(WakeOnLAN.new({
|
||||
name = "Zeus",
|
||||
room = "Living Room",
|
||||
topic = mqtt_automation("appliance/living_room/zeus"),
|
||||
client = automation.mqtt_client,
|
||||
client = mqtt_client,
|
||||
mac_address = "30:9c:23:60:9c:13",
|
||||
broadcast_ip = "10.0.0.255",
|
||||
}))
|
||||
@@ -69,7 +78,7 @@ automation.device_manager:add(living_speakers)
|
||||
automation.device_manager:add(AudioSetup.new({
|
||||
identifier = "living_audio",
|
||||
topic = mqtt_z2m("living/remote"),
|
||||
client = automation.mqtt_client,
|
||||
client = mqtt_client,
|
||||
mixer = living_mixer,
|
||||
speakers = living_speakers,
|
||||
}))
|
||||
@@ -79,7 +88,7 @@ automation.device_manager:add(IkeaOutlet.new({
|
||||
name = "Kettle",
|
||||
room = "Kitchen",
|
||||
topic = mqtt_z2m("kitchen/kettle"),
|
||||
client = automation.mqtt_client,
|
||||
client = mqtt_client,
|
||||
timeout = debug and 5 or 300,
|
||||
remotes = {
|
||||
{ topic = mqtt_z2m("bedroom/remote") },
|
||||
@@ -92,14 +101,14 @@ automation.device_manager:add(IkeaOutlet.new({
|
||||
name = "Light",
|
||||
room = "Bathroom",
|
||||
topic = mqtt_z2m("batchroom/light"),
|
||||
client = automation.mqtt_client,
|
||||
client = mqtt_client,
|
||||
timeout = debug and 60 or 45 * 60,
|
||||
}))
|
||||
|
||||
automation.device_manager:add(Washer.new({
|
||||
identifier = "bathroom_washer",
|
||||
topic = mqtt_z2m("batchroom/washer"),
|
||||
client = automation.mqtt_client,
|
||||
client = mqtt_client,
|
||||
threshold = 1,
|
||||
event_channel = automation.event_channel,
|
||||
}))
|
||||
@@ -109,7 +118,7 @@ automation.device_manager:add(IkeaOutlet.new({
|
||||
name = "Charger",
|
||||
room = "Workbench",
|
||||
topic = mqtt_z2m("workbench/charger"),
|
||||
client = automation.mqtt_client,
|
||||
client = mqtt_client,
|
||||
timeout = debug and 5 or 20 * 3600,
|
||||
}))
|
||||
|
||||
@@ -117,7 +126,7 @@ automation.device_manager:add(IkeaOutlet.new({
|
||||
name = "Outlet",
|
||||
room = "Workbench",
|
||||
topic = mqtt_z2m("workbench/outlet"),
|
||||
client = automation.mqtt_client,
|
||||
client = mqtt_client,
|
||||
}))
|
||||
|
||||
local hallway_lights = automation.device_manager:add(HueGroup.new({
|
||||
@@ -130,13 +139,13 @@ local hallway_lights = automation.device_manager:add(HueGroup.new({
|
||||
remotes = {
|
||||
{ topic = mqtt_z2m("hallway/remote") },
|
||||
},
|
||||
client = automation.mqtt_client,
|
||||
client = mqtt_client,
|
||||
}))
|
||||
|
||||
automation.device_manager:add(ContactSensor.new({
|
||||
identifier = "hallway_frontdoor",
|
||||
topic = mqtt_z2m("hallway/frontdoor"),
|
||||
client = automation.mqtt_client,
|
||||
client = mqtt_client,
|
||||
presence = {
|
||||
topic = mqtt_automation("presence/contact/frontdoor"),
|
||||
timeout = debug and 10 or 15 * 60,
|
||||
@@ -151,7 +160,7 @@ local bedroom_air_filter = automation.device_manager:add(AirFilter.new({
|
||||
name = "Air Filter",
|
||||
room = "Bedroom",
|
||||
topic = "pico/filter/bedroom",
|
||||
client = automation.mqtt_client,
|
||||
client = mqtt_client,
|
||||
}))
|
||||
|
||||
-- TODO: Use the wrapped device bedroom_air_filter instead of the string
|
||||
|
||||
Reference in New Issue
Block a user