diff --git a/app/src/main/java/io/homeassistant/companion/android/vehicle/EntityGridVehicleScreen.kt b/app/src/main/java/io/homeassistant/companion/android/vehicle/EntityGridVehicleScreen.kt index d87532c6ce9..01205b17fa9 100644 --- a/app/src/main/java/io/homeassistant/companion/android/vehicle/EntityGridVehicleScreen.kt +++ b/app/src/main/java/io/homeassistant/companion/android/vehicle/EntityGridVehicleScreen.kt @@ -24,11 +24,13 @@ import com.mikepenz.iconics.utils.sizeDp import com.mikepenz.iconics.utils.toAndroidIconCompat import io.homeassistant.companion.android.common.R import io.homeassistant.companion.android.common.data.integration.Entity +import io.homeassistant.companion.android.common.data.integration.EntityExt import io.homeassistant.companion.android.common.data.integration.IntegrationRepository import io.homeassistant.companion.android.common.data.integration.domain import io.homeassistant.companion.android.common.data.integration.friendlyName import io.homeassistant.companion.android.common.data.integration.friendlyState import io.homeassistant.companion.android.common.data.integration.getIcon +import io.homeassistant.companion.android.common.data.integration.isActive import io.homeassistant.companion.android.common.data.integration.isExecuting import io.homeassistant.companion.android.common.data.integration.onPressed import io.homeassistant.companion.android.common.data.prefs.PrefsRepository @@ -212,7 +214,16 @@ class EntityGridVehicleScreen( sizeDp = 64 }.toAndroidIconCompat() ) - .setTint(CarColor.DEFAULT) + .setTint( + if (entity.isActive() && entity.domain in EntityExt.STATE_COLORED_DOMAINS) { + CarColor.createCustom( + carContext.getColor(R.color.colorYellow), + carContext.getColor(R.color.colorYellow) + ) + } else { + CarColor.DEFAULT + } + ) .build() ) } diff --git a/app/src/main/java/io/homeassistant/companion/android/vehicle/MapVehicleScreen.kt b/app/src/main/java/io/homeassistant/companion/android/vehicle/MapVehicleScreen.kt index 7b0a0731fd9..6214b43f264 100644 --- a/app/src/main/java/io/homeassistant/companion/android/vehicle/MapVehicleScreen.kt +++ b/app/src/main/java/io/homeassistant/companion/android/vehicle/MapVehicleScreen.kt @@ -24,11 +24,13 @@ import com.mikepenz.iconics.utils.sizeDp import com.mikepenz.iconics.utils.toAndroidIconCompat import io.homeassistant.companion.android.common.R import io.homeassistant.companion.android.common.data.integration.Entity +import io.homeassistant.companion.android.common.data.integration.EntityExt import io.homeassistant.companion.android.common.data.integration.IntegrationRepository import io.homeassistant.companion.android.common.data.integration.domain import io.homeassistant.companion.android.common.data.integration.friendlyName import io.homeassistant.companion.android.common.data.integration.friendlyState import io.homeassistant.companion.android.common.data.integration.getIcon +import io.homeassistant.companion.android.common.data.integration.isActive import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.launch import io.homeassistant.companion.android.common.R as commonR @@ -103,7 +105,16 @@ class MapVehicleScreen( sizeDp = 64 }.toAndroidIconCompat() ) - .setTint(CarColor.DEFAULT) + .setTint( + if (pair.first.isActive() && pair.first.domain in EntityExt.STATE_COLORED_DOMAINS) { + CarColor.createCustom( + carContext.getColor(R.color.colorYellow), + carContext.getColor(R.color.colorYellow) + ) + } else { + CarColor.DEFAULT + } + ) .build() ) .setOnClickListener { 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 a8d3e61ca1c..6a40382fad9 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 @@ -53,6 +53,38 @@ object EntityExt { "scene", "script" ) + + val STATE_COLORED_DOMAINS = listOf( + "alarm_control_panel", + "alert", + "automation", + "binary_sensor", + "calendar", + "camera", + "climate", + "cover", + "device_tracker", + "fan", + "group", + "humidifier", + "input_boolean", + "lawn_mower", + "light", + "lock", + "media_player", + "person", + "plant", + "remote", + "schedule", + "script", + "siren", + "sun", + "switch", + "timer", + "update", + "vacuum", + "water_heater" + ) } val Entity.domain: String @@ -746,3 +778,23 @@ fun Entity.isExecuting() = when (state) { "unlocking" -> true else -> false } + +fun Entity.isActive() = when { + // https://github.com/home-assistant/frontend/blob/dev/src/common/entity/state_active.ts + (domain in listOf("button", "input_button", "event", "scene")) -> state != "unavailable" + (state == "unavailable" || state == "unknown") -> false + (state == "off" && domain != "alert") -> false + (domain == "alarm_control_panel") -> state != "disarmed" + (domain == "alert") -> state != "idle" + (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" + (domain == "media_player") -> state != "standby" + (domain == "vacuum") -> state !in listOf("idle", "docked", "paused") + (domain == "plant") -> state == "problem" + (domain == "group") -> state in listOf("on", "home", "open", "locked", "problem") + (domain == "timer") -> state == "active" + (domain == "camera") -> state == "streaming" + else -> true +} diff --git a/common/src/main/res/values/colors.xml b/common/src/main/res/values/colors.xml index b02635e181d..69f8f10accf 100644 --- a/common/src/main/res/values/colors.xml +++ b/common/src/main/res/values/colors.xml @@ -29,6 +29,7 @@ #1fffa600 #ffa600 #FDD663 + #F6C344 #9AA0A6 #8AB4F8 #FF8B66 diff --git a/wear/src/main/java/io/homeassistant/companion/android/theme/Color.kt b/wear/src/main/java/io/homeassistant/companion/android/theme/Color.kt index ce58654482c..b25a3d4f73b 100644 --- a/wear/src/main/java/io/homeassistant/companion/android/theme/Color.kt +++ b/wear/src/main/java/io/homeassistant/companion/android/theme/Color.kt @@ -5,7 +5,7 @@ import androidx.wear.compose.material.Colors val Blue = Color(0xFF03A9F4) val BlueDark = Color(0xFF0288D1) -val Yellow = Color(0xFFFDD835) +val Yellow = Color(0xFFF6C344) val Orange = Color(0xFFFF9800) val Red = Color(0xFFD32F2F)