Can set relay forced state from UI
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user