From a31cd2fdaa834477c74997a61a99632591ae8ae0 Mon Sep 17 00:00:00 2001 From: Lev Aronsky Date: Tue, 19 Sep 2023 22:40:07 +0300 Subject: [PATCH] Fix isActive for locks (#3862) * Fix isActive for locks Lock entity should be active when locked, inactive otherwise * Added a comment to explain the change --- .../companion/android/common/data/integration/Entity.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/integration/Entity.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/integration/Entity.kt index 1b0f4507dbd..42d4e70958a 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/integration/Entity.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/integration/Entity.kt @@ -829,7 +829,8 @@ fun Entity.isActive() = when { (domain == "cover") -> state != "closed" (domain in listOf("device_tracker", "person")) -> state != "not_home" (domain == "lawn_mower") -> state in listOf("mowing", "error") - (domain == "lock") -> state != "locked" + // on Android, contrary to HA Frontend, a lock is considered active when locked + (domain == "lock") -> state == "locked" (domain == "media_player") -> state != "standby" (domain == "vacuum") -> state !in listOf("idle", "docked", "paused") (domain == "plant") -> state == "problem"