mirror of
https://github.com/home-assistant/android
synced 2024-09-18 23:52:51 +00:00
Power Menu button enhancements (#1061)
* Power Menu button enhancements * Map more states for status text
This commit is contained in:
parent
44d8af97e9
commit
8972742244
|
@ -34,6 +34,18 @@ class ClimateControl {
|
|||
control.setTitle(entity.attributes["friendly_name"].toString())
|
||||
control.setDeviceType(DeviceTypes.TYPE_AC_HEATER)
|
||||
control.setStatus(Control.STATUS_OK)
|
||||
control.setStatusText(
|
||||
when (entity.state) {
|
||||
"auto" -> "Auto"
|
||||
"cool" -> "Cool"
|
||||
"dry" -> "Dry"
|
||||
"fan_only" -> "Fan Only"
|
||||
"heat" -> "Heat"
|
||||
"heat_cool" -> "Heat Cool"
|
||||
"off" -> "Off"
|
||||
else -> entity.state
|
||||
}
|
||||
)
|
||||
control.setControlTemplate(
|
||||
RangeTemplate(
|
||||
entity.entityId,
|
||||
|
@ -41,7 +53,7 @@ class ClimateControl {
|
|||
100f,
|
||||
(entity.attributes["temperature"] as? Number)?.toFloat() ?: 0f,
|
||||
.5f,
|
||||
""
|
||||
"%.0f"
|
||||
)
|
||||
|
||||
)
|
||||
|
|
|
@ -31,8 +31,28 @@ class CoverControl {
|
|||
)
|
||||
)
|
||||
control.setTitle(entity.attributes["friendly_name"].toString())
|
||||
control.setDeviceType(DeviceTypes.TYPE_GARAGE)
|
||||
control.setDeviceType(
|
||||
when (entity.attributes["device_class"]) {
|
||||
"awning" -> DeviceTypes.TYPE_AWNING
|
||||
"blind" -> DeviceTypes.TYPE_BLINDS
|
||||
"curtain" -> DeviceTypes.TYPE_CURTAIN
|
||||
"door" -> DeviceTypes.TYPE_DOOR
|
||||
"garage" -> DeviceTypes.TYPE_GARAGE
|
||||
"gate" -> DeviceTypes.TYPE_GATE
|
||||
"shutter" -> DeviceTypes.TYPE_SHUTTER
|
||||
"window" -> DeviceTypes.TYPE_WINDOW
|
||||
else -> DeviceTypes.TYPE_GENERIC_OPEN_CLOSE
|
||||
}
|
||||
)
|
||||
control.setStatus(Control.STATUS_OK)
|
||||
control.setStatusText(
|
||||
when (entity.state) {
|
||||
"closed" -> "Closed"
|
||||
"closing" -> "Closing"
|
||||
"open" -> "Open"
|
||||
"opening" -> "Opening"
|
||||
else -> entity.state
|
||||
})
|
||||
control.setControlTemplate(
|
||||
ToggleTemplate(
|
||||
entity.entityId,
|
||||
|
|
|
@ -32,8 +32,14 @@ class DefaultSwitchControl {
|
|||
)
|
||||
)
|
||||
control.setTitle(entity.attributes["friendly_name"].toString())
|
||||
control.setDeviceType(DeviceTypes.TYPE_GENERIC_ON_OFF)
|
||||
control.setDeviceType(
|
||||
when (entity.entityId.split(".")[0]) {
|
||||
"switch" -> DeviceTypes.TYPE_SWITCH
|
||||
else -> DeviceTypes.TYPE_GENERIC_ON_OFF
|
||||
}
|
||||
)
|
||||
control.setStatus(Control.STATUS_OK)
|
||||
control.setStatusText(if (entity.state == "off") "Off" else "On")
|
||||
control.setControlTemplate(
|
||||
ToggleTemplate(
|
||||
entity.entityId,
|
||||
|
|
|
@ -35,6 +35,7 @@ class LightControl {
|
|||
control.setTitle(entity.attributes["friendly_name"].toString())
|
||||
control.setDeviceType(DeviceTypes.TYPE_LIGHT)
|
||||
control.setStatus(Control.STATUS_OK)
|
||||
control.setStatusText(if (entity.state == "off") "Off" else "On")
|
||||
control.setControlTemplate(
|
||||
ToggleRangeTemplate(
|
||||
entity.entityId,
|
||||
|
@ -44,9 +45,12 @@ class LightControl {
|
|||
entity.entityId,
|
||||
0f,
|
||||
255f,
|
||||
(entity.attributes["brightness"] as? Number)?.toFloat() ?: 0f,
|
||||
(entity.attributes["brightness"] as? Number)
|
||||
?.toFloat()
|
||||
?.div(255f)
|
||||
?.times(100) ?: 0f,
|
||||
1f,
|
||||
""
|
||||
"%.0f%%"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue