findmydevice 워치 표시 제거 및 빈 섹션 숨김
This commit is contained in:
1 parent
b13809feea
commit
d49bafe3d5
2 files changed
+88
-104
No files matched your search
+3
-43
@@ -530,38 +530,6 @@ function findmydevice_starts_with(string $value, string $prefix): bool
|
||||
{
|
||||
return strncmp($value, $prefix, strlen($prefix)) === 0;
|
||||
}
|
||||
function findmydevice_watch_pair_key(string $key): ?string
|
||||
{
|
||||
if (!findmydevice_starts_with($key, 'watch') || strlen($key) <= 5) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return lcfirst(substr($key, 5));
|
||||
}
|
||||
|
||||
function findmydevice_pair_watch_sensor_rows(array $rows): array
|
||||
{
|
||||
$ordered = [];
|
||||
foreach ($rows as $key => $value) {
|
||||
if (findmydevice_watch_pair_key((string)$key) !== null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ordered[$key] = $value;
|
||||
$watchKey = 'watch' . ucfirst((string)$key);
|
||||
if (array_key_exists($watchKey, $rows)) {
|
||||
$ordered[$watchKey] = $rows[$watchKey];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($rows as $key => $value) {
|
||||
if (!array_key_exists($key, $ordered)) {
|
||||
$ordered[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $ordered;
|
||||
}
|
||||
|
||||
|
||||
function readableTriggerCode(string $value, string $lang): string
|
||||
@@ -723,8 +691,6 @@ $deviceData = getData($deviceUrl);
|
||||
$geoData = getData($geoUrl);
|
||||
$batteryStateData = getData($batteryStateUrl);
|
||||
$batteryLevelData = getData($batteryLevelUrl);
|
||||
$watchBatteryStateData = getEntityData($entities, 'watch_battery_state');
|
||||
$watchBatteryLevelData = getEntityData($entities, 'watch_battery_level');
|
||||
$activityData = getData($activityUrl);
|
||||
$connectionData = getData($connectionUrl);
|
||||
$ascendedData = getData($fascendedUrl);
|
||||
@@ -1294,9 +1260,6 @@ $activityState = $activityData['state'] ?? null;
|
||||
$aaccuracyState = $activityData['attributes']['Confidence'] ?? $activityData['attributes']['confidence'] ?? null;
|
||||
$connectionState = $connectionData['state'] ?? null;
|
||||
$batteryState = $batteryStateData['state'] ?? null;
|
||||
$watchBatteryState = stateValue($watchBatteryStateData);
|
||||
$watchBatteryLevel = stateValue($watchBatteryLevelData);
|
||||
$watchBatteryText = $batteryStateMap[$lang][$watchBatteryState] ?? $watchBatteryState ?? null;
|
||||
$highAccuracyMode = strtolower((string)($highAccuracyModeData['state'] ?? '')) === 'on';
|
||||
|
||||
$address = null;
|
||||
@@ -1321,6 +1284,9 @@ $flatSensors = [];
|
||||
foreach (($config['findmydevice_sensor_sections'] ?? []) as $sectionKey => $definitions) {
|
||||
$sensorSections[$sectionKey] = [];
|
||||
foreach ($definitions as $sensorKey => $definition) {
|
||||
if (!is_array($definition)) {
|
||||
continue;
|
||||
}
|
||||
if (!empty($definition['requires']) && empty($flatSensors[$definition['requires']])) {
|
||||
continue;
|
||||
}
|
||||
@@ -1334,8 +1300,6 @@ foreach (($config['findmydevice_sensor_sections'] ?? []) as $sectionKey => $defi
|
||||
}
|
||||
if (!$sensorSections[$sectionKey]) {
|
||||
unset($sensorSections[$sectionKey]);
|
||||
} else {
|
||||
$sensorSections[$sectionKey] = findmydevice_pair_watch_sensor_rows($sensorSections[$sectionKey]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1350,8 +1314,6 @@ if (isset($_GET['hashonly']) && $_GET['hashonly'] == '1') {
|
||||
'address' => $address,
|
||||
'state' => $batteryStateMap[$lang][$batteryState] ?? $batteryState ?? null,
|
||||
'level' => $batteryLevelData['state'] ?? null,
|
||||
'wstate' => $watchBatteryText,
|
||||
'wlevel' => $watchBatteryLevel,
|
||||
'ascended' => $ascendedData['state'] ?? null,
|
||||
'descended' => $descendedData['state'] ?? null,
|
||||
'steps' => $stepsData['state'] ?? null,
|
||||
@@ -1378,8 +1340,6 @@ echo json_encode([
|
||||
'address' => $address,
|
||||
'state' => $batteryStateMap[$lang][$batteryState] ?? $batteryState ?? null,
|
||||
'level' => $batteryLevelData['state'] ?? null,
|
||||
'wstate' => $watchBatteryText,
|
||||
'wlevel' => $watchBatteryLevel,
|
||||
'ascended' => $ascendedData['state'] ?? null,
|
||||
'descended' => $descendedData['state'] ?? null,
|
||||
'steps' => $stepsData['state'] ?? null,
|
||||
|
||||
Reference in new issue
Block a user