Skip to content

Commit 77a5b1c

Browse files
eyal0Copilot
andcommitted
# This is a combination of 2 commits.
# This is the 1st commit message: Fix missing home zone on the first location update after high accuracy mode turns off # This is the commit message #2: Potential fix for pull request finding Use junit without jupiter. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 532638a commit 77a5b1c

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

app/src/full/kotlin/io/homeassistant/companion/android/sensors/LocationSensorManager.kt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,9 @@ class LocationSensorManager @Inject constructor(
924924
val inZones = zones
925925
.filter {
926926
val radius = it.attributes["radius"] as? Number
927-
return@filter radius != null && it.containsWithAccuracy(location)
927+
val matchesGps = radius != null && it.containsWithAccuracy(location)
928+
val matchesGeofence = lastEnteredGeoZones.contains("${serverId}_${it.entityId}")
929+
return@filter matchesGps || matchesGeofence
928930
}.sortedWith(
929931
// Smallest zone (radius) first; when two zones share the same radius, prefer the one
930932
// whose center is closest to the current location to break the tie deterministically.
@@ -958,11 +960,20 @@ class LocationSensorManager @Inject constructor(
958960
)
959961
updateLocationString = locationName
960962
} else {
963+
val enteredZoneIds = getZones(serverId).map { it.entityId }.filter { entityId ->
964+
lastEnteredGeoZones.contains("${serverId}_$entityId")
965+
}
961966
updateLocation = UpdateLocation(
962967
gps = listOf(location.latitude, location.longitude),
963968
gpsAccuracy = accuracy,
964969
locationName = null,
965-
inZones = null,
970+
inZones = if (enteredZoneIds.isNotEmpty() &&
971+
serverManager.getServer(serverId)?.version?.isAtLeast(2026, 6, 0) == true
972+
) {
973+
enteredZoneIds
974+
} else {
975+
null
976+
},
966977
speed = location.speed.toInt(),
967978
altitude = location.altitude.toInt(),
968979
course = location.bearing.toInt(),
@@ -989,7 +1000,7 @@ class LocationSensorManager @Inject constructor(
9891000
return
9901001
}
9911002

992-
if (location.time < (lastLocationSend[serverId] ?: 0)) {
1003+
if (location.time < (lastLocationSend[serverId] ?: 0) && trigger?.isGeofence != true) {
9931004
Timber.d(
9941005
"Skipping old location update since time is before the last one we sent, received: ${location.time} last sent: $lastLocationSend",
9951006
)
@@ -1002,7 +1013,7 @@ class LocationSensorManager @Inject constructor(
10021013
"Received location that is ${now - location.time} milliseconds old, ${location.time} compared to $now with source ${location.provider}",
10031014
)
10041015
if (lastUpdateLocation[serverId] == updateLocationString) {
1005-
if (now < (lastLocationSend[serverId] ?: 0) + 900000) {
1016+
if (now < (lastLocationSend[serverId] ?: 0) + 900000 && trigger?.isGeofence != true) {
10061017
Timber.d("Duplicate location received, not sending to HA")
10071018
logLocationUpdate(
10081019
location,

app/src/main/res/xml/changelog_master.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<changelog xmlns:tools="http://schemas.android.com/tools"
33
tools:ignore="MissingDefaultResource">
44
<release version="2026.8.4 - Main" versioncode="3">
5+
<change>Fix missing zone on the first location update after high accuracy mode turns off</change>
56
<change>Android 17: added assistant volume level sensor + notification command for control</change>
67
<change>Health Connect sleep duration sensor now ignores awake and out of bed time</change>
78
<change>Modernized settings for entity widgets and tiles</change>
@@ -12,6 +13,7 @@
1213
<change>Bug fixes and dependency updates</change>
1314
</release>
1415
<release version="2026.8.4 - Automotive" versioncode="1">
16+
<change>Fix missing zone on the first location update after high accuracy mode turns off</change>
1517
<change>Android 17: added assistant volume level sensor + notification command for control</change>
1618
<change>Health Connect sleep duration sensor now ignores awake and out of bed time</change>
1719
<change>Bug fixes and dependency updates</change>

0 commit comments

Comments
 (0)