findmydevice 충전 중 자동 추적 조건 복원

This commit is contained in:
seo
2026-07-10 20:17:51 +09:00
parent debb6ead7a
commit 93b41b2edb
2 changed files with 22 additions and 4 deletions
+21 -3
View File
@@ -218,16 +218,30 @@ function findmydevice_required_bluetooth_connected(): bool
return false;
}
function findmydevice_is_charging(): bool
{
$config = custom_config();
$entity = (string)($config['entities']['is_charging'] ?? '');
if ($entity === '') {
return false;
}
$state = findmydevice_latest_state($entity);
return strtolower((string)($state['state'] ?? '')) === 'on';
}
function findmydevice_auto_tracking_policy(): array
{
$position = findmydevice_current_position();
$zone = findmydevice_quiet_zone($position);
$bluetooth = findmydevice_required_bluetooth_connected();
$charging = findmydevice_is_charging();
return [
'allowed' => !$zone && $bluetooth,
'allowed' => !$zone && ($charging || $bluetooth),
'position' => $position,
'quiet_zone' => $zone,
'charging' => $charging,
'required_bluetooth_connected' => $bluetooth,
];
}
@@ -254,6 +268,7 @@ function findmydevice_location_refresh(string $name): array
if (!$policy['allowed']) {
$results['policy'] = 'blocked';
$results['quietZone'] = $policy['quiet_zone'];
$results['charging'] = $policy['charging'];
$results['requiredBluetoothConnected'] = $policy['required_bluetooth_connected'];
$results['allowWebhook'] = false;
$results['high_accuracy_off'] = findmydevice_mobile_command('command_high_accuracy_mode', [
@@ -264,7 +279,8 @@ function findmydevice_location_refresh(string $name): array
$results['policy'] = 'allowed';
$results['quietZone'] = null;
$results['requiredBluetoothConnected'] = true;
$results['charging'] = $policy['charging'];
$results['requiredBluetoothConnected'] = $policy['required_bluetooth_connected'];
$results['high_accuracy_interval'] = findmydevice_mobile_command('command_high_accuracy_mode', [
'command' => 'high_accuracy_set_update_interval',
'high_accuracy_update_interval' => $interval,
@@ -279,6 +295,7 @@ function findmydevice_location_refresh(string $name): array
if (!$policy['allowed']) {
$results['policy'] = 'blocked';
$results['quietZone'] = $policy['quiet_zone'];
$results['charging'] = $policy['charging'];
$results['requiredBluetoothConnected'] = $policy['required_bluetooth_connected'];
$results['allowWebhook'] = false;
$results['high_accuracy_off'] = findmydevice_mobile_command('command_high_accuracy_mode', [
@@ -289,7 +306,8 @@ function findmydevice_location_refresh(string $name): array
$results['policy'] = 'allowed';
$results['quietZone'] = null;
$results['requiredBluetoothConnected'] = true;
$results['charging'] = $policy['charging'];
$results['requiredBluetoothConnected'] = $policy['required_bluetooth_connected'];
$results['request_location'] = findmydevice_mobile_command('request_location_update');
$results['update_sensors'] = findmydevice_mobile_command('command_update_sensors');
} elseif ($name === 'force_update') {