Compare commits
5 Commits
feature/im
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
8c6adae3ae
|
|||
|
2158bde1c2
|
|||
|
b547f66d86
|
|||
|
f3de8e36ea
|
|||
|
44f2c57819
|
@@ -9,10 +9,10 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
uses: dreaded_x/workflows/.gitea/workflows/rust-kubernetes.yaml@22ee0c1788a8d2157db87d6a6f8dbe520fe48592
|
||||
uses: dreaded_x/workflows/.gitea/workflows/docker-kubernetes.yaml@ef78704b98c72e4a6b8340f9bff7b085a7bdd95c
|
||||
secrets: inherit
|
||||
with:
|
||||
upload_manifests: false
|
||||
push_manifests: false
|
||||
|
||||
deploy:
|
||||
name: Deploy container
|
||||
@@ -37,7 +37,7 @@ 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 }} \
|
||||
git.huizinga.dev/dreaded_x/automation_rs@${{ needs.build.outputs.digest }}
|
||||
$(echo ${{ toJSON(needs.build.outputs.images) }} | jq .automation -r)
|
||||
|
||||
docker network connect web automation_rs
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
|
||||
RUN cargo install cargo-chef --locked --version 0.1.71 && \
|
||||
cargo install cargo-auditable --locked --version 0.6.6
|
||||
WORKDIR /app
|
||||
COPY ./rust-toolchain.toml .
|
||||
RUN rustup toolchain install
|
||||
|
||||
FROM base AS planner
|
||||
COPY . .
|
||||
@@ -21,5 +23,7 @@ RUN cargo auditable build --release
|
||||
|
||||
FROM gcr.io/distroless/cc-debian12:nonroot AS runtime
|
||||
COPY --from=builder /app/target/release/automation /app/automation
|
||||
ENV AUTOMATION__ENTRYPOINT=/app/config/config.lua
|
||||
ENV LUA_PATH="/app/?.lua;;"
|
||||
COPY ./config /app/config
|
||||
CMD [ "/app/automation" ]
|
||||
|
||||
@@ -25,10 +25,18 @@ function module.setup(mqtt_client)
|
||||
})
|
||||
windows.add(window)
|
||||
|
||||
local printer = devices.OutletOnOff.new({
|
||||
name = "3D Printer",
|
||||
room = "Guest Room",
|
||||
topic = helper.mqtt_z2m("guest/printer"),
|
||||
client = mqtt_client,
|
||||
})
|
||||
|
||||
--- @type Module
|
||||
return {
|
||||
light,
|
||||
window,
|
||||
printer,
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -59,26 +59,21 @@ function module.setup(mqtt_client)
|
||||
})
|
||||
hallway_automation.set_trash(trash)
|
||||
|
||||
---@param duration number
|
||||
---@return fun(_, open: boolean)
|
||||
local function frontdoor_presence(duration)
|
||||
local timeout = utils.Timeout.new()
|
||||
local timeout = utils.Timeout.new()
|
||||
local function frontdoor_presence(_, open)
|
||||
if open then
|
||||
timeout:cancel()
|
||||
|
||||
return function(_, open)
|
||||
if open then
|
||||
timeout:cancel()
|
||||
|
||||
if presence.overall_presence() then
|
||||
mqtt_client:send_message(helper.mqtt_automation("presence/contact/frontdoor"), {
|
||||
state = true,
|
||||
updated = utils.get_epoch(),
|
||||
})
|
||||
end
|
||||
else
|
||||
timeout:start(duration, function()
|
||||
mqtt_client:send_message(helper.mqtt_automation("presence/contact/frontdoor"), nil)
|
||||
end)
|
||||
if not presence.overall_presence() then
|
||||
mqtt_client:send_message(helper.mqtt_automation("presence/contact/frontdoor"), {
|
||||
state = true,
|
||||
updated = utils.get_epoch(),
|
||||
})
|
||||
end
|
||||
else
|
||||
timeout:start(debug.debug_mode and 10 or 15 * 60, function()
|
||||
mqtt_client:send_message(helper.mqtt_automation("presence/contact/frontdoor"), nil)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -89,7 +84,7 @@ function module.setup(mqtt_client)
|
||||
topic = helper.mqtt_z2m("hallway/frontdoor"),
|
||||
client = mqtt_client,
|
||||
callback = {
|
||||
frontdoor_presence(debug.debug_mode and 10 or 15 * 60),
|
||||
frontdoor_presence,
|
||||
hallway_automation.door_callback,
|
||||
},
|
||||
battery_callback = battery.callback,
|
||||
|
||||
18
docker-bake.hcl
Normal file
18
docker-bake.hcl
Normal file
@@ -0,0 +1,18 @@
|
||||
variable "TAG_BASE" {}
|
||||
variable "RELEASE_VERSION" {}
|
||||
|
||||
group "default" {
|
||||
targets = ["automation"]
|
||||
}
|
||||
|
||||
target "docker-metadata-action" {}
|
||||
|
||||
target "automation" {
|
||||
inherits = ["docker-metadata-action"]
|
||||
context = "./"
|
||||
dockerfile = "Dockerfile"
|
||||
tags = [for tag in target.docker-metadata-action.tags : "${TAG_BASE}:${tag}"]
|
||||
args = {
|
||||
RELEASE_VERSION="${RELEASE_VERSION}"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user