Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 1x 20x 20x 10x 10x 10x 10x | import { EufySecurity } from "eufy-security-client";
import { Modify } from "../state.js";
export interface DriverStateSchema0 {
version: string;
connected: boolean;
pushConnected: boolean;
}
type DriverStateSchema1 = Modify<
DriverStateSchema0,
{ mqttConnected: boolean }
>;
export type DriverState = DriverStateSchema0 | DriverStateSchema1;
export const dumpDriver = (
driver: EufySecurity,
schemaVersion: number,
): DriverState => {
const base: Partial<DriverStateSchema0> = {
version: driver.getVersion(),
connected: driver.isConnected(),
pushConnected: driver.isPushConnected(),
};
if (schemaVersion <= 8) {
return base as DriverStateSchema0;
}
// All schemas >= 9
const driver1 = base as DriverStateSchema1;
driver1.mqttConnected = driver.isMQTTConnected();
return driver1;
};
|