Can set relay forced state from UI
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-29 17:49:03 +01:00
parent 88a24565b4
commit abdca20a66
6 changed files with 178 additions and 10 deletions

View File

@@ -1,10 +1,19 @@
import { APIClient } from "./ApiClient";
import { Device, DeviceRelay } from "./DeviceApi";
export type RelayForcedState =
| { type: "None" }
| { type: "Off" | "On"; until: number };
export type SetRelayForcedState =
| { type: "None" }
| { type: "Off" | "On"; for_secs: number };
export interface RelayStatus {
id: string;
on: boolean;
for: number;
forced_state: RelayForcedState;
}
export type RelaysStatus = Map<string, RelayStatus>;
@@ -48,6 +57,20 @@ export class RelayApi {
});
}
/**
* Set relay forced state
*/
static async SetForcedState(
relay: DeviceRelay,
forced: SetRelayForcedState
): Promise<void> {
await APIClient.exec({
method: "PUT",
uri: `/relay/${relay.id}/forced_state`,
jsonData: forced,
});
}
/**
* Delete a relay configuration
*/