First Commit

This commit is contained in:
Carsten Graf
2026-03-05 14:52:36 +01:00
commit d5353b3c2b
24 changed files with 3893 additions and 0 deletions

43
src/actions/home-axes.ts Normal file
View File

@@ -0,0 +1,43 @@
// src/actions/home-axes.ts
import streamDeck, { action, KeyDownEvent, SingletonAction } from "@elgato/streamdeck";
import { OctoPrintClient, OctoPrintSettings } from "../octoprint-client";
@action({ UUID: "com.octoprint.monitor.home-axes" })
export class HomeAxesAction extends SingletonAction {
override async onKeyDown(ev: KeyDownEvent): Promise<void> {
const settings = ev.payload.settings as unknown as OctoPrintSettings;
if (!settings?.host || !settings?.apiKey) {
await ev.action.setTitle("Configure");
return;
}
const client = new OctoPrintClient(settings);
try {
const printer = await client.getPrinterState();
if (printer.state.flags.printing) {
await ev.action.setTitle("Printing!\nBlocked");
setTimeout(() => ev.action.setTitle("Home"), 2000);
return;
}
if (!printer.state.flags.operational) {
await ev.action.setTitle("Offline");
setTimeout(() => ev.action.setTitle("Home"), 2000);
return;
}
await ev.action.setTitle("Homing…");
await client.homeAxes(["x", "y", "z"]);
await ev.action.setTitle("✓ Homed");
setTimeout(() => ev.action.setTitle("Home"), 2000);
} catch (err) {
streamDeck.logger.error("HomeAxes: failed", err);
await ev.action.setTitle("⚠️ Error");
setTimeout(() => ev.action.setTitle("Home"), 2000);
}
}
}