@@ -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,
0 commit comments