고정밀 위치 추적 제어 조건 정리
This commit is contained in:
+31
-9
@@ -229,6 +229,34 @@ function findmydevice_is_charging(): bool
|
||||
return strtolower((string)($state['state'] ?? '')) === 'on';
|
||||
}
|
||||
|
||||
function findmydevice_high_accuracy_mode_active(): bool
|
||||
{
|
||||
$config = custom_config();
|
||||
$entity = (string)($config['entities']['high_accuracy_mode'] ?? 'binary_sensor.seocaegeonyi_z_fold7_high_accuracy_mode');
|
||||
if ($entity === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$state = findmydevice_latest_state($entity);
|
||||
return strtolower((string)($state['state'] ?? '')) === 'on';
|
||||
}
|
||||
|
||||
function findmydevice_high_accuracy_off_result(): array
|
||||
{
|
||||
if (findmydevice_high_accuracy_mode_active()) {
|
||||
return [
|
||||
'skipped' => true,
|
||||
'reason' => 'high_accuracy_mode_active',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'sent' => findmydevice_mobile_command('command_high_accuracy_mode', [
|
||||
'command' => 'force_off',
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
function findmydevice_auto_tracking_policy(): array
|
||||
{
|
||||
$position = findmydevice_current_position();
|
||||
@@ -270,9 +298,7 @@ function findmydevice_location_refresh(string $name): array
|
||||
$results['charging'] = $policy['charging'];
|
||||
$results['requiredBluetoothConnected'] = $policy['required_bluetooth_connected'];
|
||||
$results['allowWebhook'] = false;
|
||||
$results['high_accuracy_off'] = findmydevice_mobile_command('command_high_accuracy_mode', [
|
||||
'command' => 'force_off',
|
||||
]);
|
||||
$results['high_accuracy_off'] = findmydevice_high_accuracy_off_result();
|
||||
return $results;
|
||||
}
|
||||
|
||||
@@ -298,9 +324,7 @@ function findmydevice_location_refresh(string $name): array
|
||||
$results['charging'] = $policy['charging'];
|
||||
$results['requiredBluetoothConnected'] = $policy['required_bluetooth_connected'];
|
||||
$results['allowWebhook'] = false;
|
||||
$results['high_accuracy_off'] = findmydevice_mobile_command('command_high_accuracy_mode', [
|
||||
'command' => 'force_off',
|
||||
]);
|
||||
$results['high_accuracy_off'] = findmydevice_high_accuracy_off_result();
|
||||
return $results;
|
||||
}
|
||||
|
||||
@@ -317,9 +341,7 @@ function findmydevice_location_refresh(string $name): array
|
||||
$results['update_sensors'] = findmydevice_mobile_command('command_update_sensors');
|
||||
} elseif ($name === 'auto_off') {
|
||||
$results['allowWebhook'] = false;
|
||||
$results['high_accuracy_off'] = findmydevice_mobile_command('command_high_accuracy_mode', [
|
||||
'command' => 'force_off',
|
||||
]);
|
||||
$results['high_accuracy_off'] = findmydevice_high_accuracy_off_result();
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
||||
Reference in New Issue
Block a user