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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | 1x 21x 21x 5x 16x 16x 16x 4x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 4x 8x 8x 8x 8x 8x | import { DeviceType, PropertyName, Station } from "eufy-security-client";
import { Modify } from "../state.js";
export interface StationStateSchema0 {
name: string;
model: string;
serialNumber: string;
hardwareVersion: string;
softwareVersion: string;
lanIpAddress: string;
macAddress: string;
currentMode: number;
guardMode: number;
connected: boolean;
}
type StationStateSchema1 = Modify<
StationStateSchema0,
{
type: DeviceType;
}
>;
type StationStateSchema3 = Modify<
StationStateSchema1,
{
timeFormat?: number;
alarmVolume?: number;
alarmTone?: number;
promptVolume?: number;
notificationSwitchModeSchedule?: boolean;
notificationSwitchModeGeofence?: boolean;
notificationSwitchModeApp?: boolean;
notificationSwitchModeKeypad?: boolean;
notificationStartAlarmDelay?: boolean;
}
>;
type StationStateSchema5 = Modify<
StationStateSchema3,
{
switchModeWithAccessCode?: boolean;
autoEndAlarm?: boolean;
turnOffAlarmWithButton?: boolean;
}
>;
export type StationState =
| StationStateSchema0
| StationStateSchema1
| StationStateSchema3
| StationStateSchema5;
export const dumpStation = (
station: Station,
schemaVersion: number,
): StationState => {
const base: Partial<StationStateSchema0> = {
name: station.getPropertyValue(PropertyName.Name) as string,
model: station.getPropertyValue(PropertyName.Model) as string,
serialNumber: station.getPropertyValue(PropertyName.SerialNumber) as string,
hardwareVersion: station.getPropertyValue(
PropertyName.HardwareVersion,
) as string,
softwareVersion: station.getPropertyValue(
PropertyName.SoftwareVersion,
) as string,
lanIpAddress: station.getPropertyValue(
PropertyName.StationLANIpAddress,
) as string,
macAddress: station.getPropertyValue(
PropertyName.StationMacAddress,
) as string,
currentMode: station.getPropertyValue(
PropertyName.StationCurrentMode,
) as number,
guardMode: station.getPropertyValue(
PropertyName.StationGuardMode,
) as number,
connected: station.isConnected(),
};
if (schemaVersion == 0) {
return base as StationStateSchema0;
}
const station1 = base as StationStateSchema1;
station1.type = station.getPropertyValue(PropertyName.Type) as number;
if (schemaVersion <= 2) {
return station1;
}
const station3 = station1 as StationStateSchema3;
station3.timeFormat = station.getPropertyValue(
PropertyName.StationTimeFormat,
) as number;
station3.alarmVolume = station.getPropertyValue(
PropertyName.StationAlarmVolume,
) as number;
station3.alarmTone = station.getPropertyValue(
PropertyName.StationAlarmTone,
) as number;
station3.promptVolume = station.getPropertyValue(
PropertyName.StationPromptVolume,
) as number;
station3.notificationSwitchModeSchedule = station.getPropertyValue(
PropertyName.StationNotificationSwitchModeSchedule,
) as boolean;
station3.notificationSwitchModeGeofence = station.getPropertyValue(
PropertyName.StationNotificationSwitchModeGeofence,
) as boolean;
station3.notificationSwitchModeApp = station.getPropertyValue(
PropertyName.StationNotificationSwitchModeApp,
) as boolean;
station3.notificationSwitchModeKeypad = station.getPropertyValue(
PropertyName.StationNotificationSwitchModeKeypad,
) as boolean;
station3.notificationStartAlarmDelay = station.getPropertyValue(
PropertyName.StationNotificationStartAlarmDelay,
) as boolean;
if (schemaVersion <= 4) {
return station3;
}
// All schemas >= 5
const station5 = station3 as StationStateSchema5;
station5.switchModeWithAccessCode = station.getPropertyValue(
PropertyName.StationSwitchModeWithAccessCode,
) as boolean;
station5.autoEndAlarm = station.getPropertyValue(
PropertyName.StationAutoEndAlarm,
) as boolean;
station5.turnOffAlarmWithButton = station.getPropertyValue(
PropertyName.StationTurnOffAlarmWithButton,
) as boolean;
return station5;
};
|