From 3cc606da45a13883eff7a66ce3e60fa946e8732c Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Fri, 19 Jun 2026 04:05:11 +0200 Subject: [PATCH] feat: Sync printer light with room light --- .gitea/workflows/build.yml | 2 ++ config/rooms/guest_bedroom.lua | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 8b9c27e..83d3ed1 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -41,6 +41,8 @@ jobs: -e AUTOMATION__SECRETS__MQTT_PASSWORD=${{ secrets.MQTT_PASSWORD }} \ -e AUTOMATION__SECRETS__HUE_TOKEN=${{ secrets.HUE_TOKEN }} \ -e AUTOMATION__SECRETS__NTFY_TOPIC=${{ secrets.NTFY_TOPIC }} \ + -e AUTOMATION__SECRETS__PRINTER_DEVICE_ID=${{ secrets.PRINTER_DEVICE_ID }} \ + -e AUTOMATION__SECRETS__PRINTER_ACCESS_CODE=${{ secrets.PRINTER_ACCESS_CODE }} \ $(echo ${{ toJSON(needs.build.outputs.images) }} | jq .automation -r) docker network connect web automation_rs diff --git a/config/rooms/guest_bedroom.lua b/config/rooms/guest_bedroom.lua index 55f313c..d364655 100644 --- a/config/rooms/guest_bedroom.lua +++ b/config/rooms/guest_bedroom.lua @@ -4,15 +4,35 @@ local helper = require("config.helper") local presence = require("config.presence") local windows = require("config.windows") +local secrets = require("automation:secrets") + --- @type Module local module = {} function module.setup(mqtt_client) - local light = devices.LightOnOff.new({ + local light = nil + + local bambu = devices.Bambu.new({ + host = "thalia.huizinga.lan", + device_id = secrets.printer_device_id, + access_code = secrets.printer_access_code, + callbacks = { + connected = function(self) + if light ~= nil then + self:set_on(light:on()) + end + end, + }, + }) + + light = devices.LightOnOff.new({ name = "Light", room = "Guest Room", topic = helper.mqtt_z2m("guest/light"), client = mqtt_client, + callback = function(_, state) + bambu:set_on(state.state) + end, }) presence.turn_off_when_away(light) @@ -37,6 +57,7 @@ function module.setup(mqtt_client) light, window, printer, + bambu, } end