mirror of
https://github.com/home-assistant/android
synced 2024-07-21 10:24:38 +00:00
Entity State Widget bugfix (#702)
* Merge branch 'master' of F:\Colin\Projects\home-assistant-android-companion-colin-cachia with conflicts. * Static Widget Bugfixes: - Safely typing any attribute to String - Removed showing of N/A when attribute not found
This commit is contained in:
parent
d747afd37c
commit
11982f9ae3
|
@ -104,10 +104,11 @@ class StaticWidget : AppWidgetProvider() {
|
|||
): CharSequence? {
|
||||
val entity = integrationUseCase.getEntities().find { e -> e.entityId.equals(entityId) }
|
||||
|
||||
if (attributeId == null) return entity?.state ?: "N/A"
|
||||
if (attributeId == null) return entity?.state
|
||||
|
||||
val fetchedAttributes = entity?.attributes as Map<String, String>
|
||||
return entity.state.plus(fetchedAttributes.get(attributeId) ?: "")
|
||||
val fetchedAttributes = entity?.attributes as Map<*, *>
|
||||
val attributeValue = fetchedAttributes.get(attributeId)?.toString()
|
||||
return entity.state.plus(if (attributeValue != null && attributeValue.isNotEmpty()) " " else "").plus(attributeValue ?: "")
|
||||
}
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
|
|
Loading…
Reference in a new issue