Android: App crashes when populating list of available entities for Power Control menu (if fan entity is present in HA)

Created on 30 Oct 2020  路  3Comments  路  Source: home-assistant/android

Home Assistant Android version: beta-488-57dad77

Android version: Android 11 (RP1A.201005.006)

Phone model: Pixel 4a

Home Assistant version: 0.117.1

Last working Home Assistant release (if known):

Description of problem:
When trying to load devices for Power Menu control in Android 11 app crashes in background and no devices are shown. Power Menu screen informs about timeout when loading devices info. Logcat points to a problem when parsing fan entity data. When I removed this (only 1) fan entity from HA - app works as expected.
Fan is a Xiaomi Air Purifier. Configuration in HA looks like this:

fan:
  - platform: xiaomi_miio
    host: 192.168.1.21
    token: !secret air3h_token
    name: Oczyszczacz

Traceback (if applicable):

10-30 20:03:07.967 22516 22568 E AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-2
10-30 20:03:07.967 22516 22568 E AndroidRuntime: Process: io.homeassistant.companion.android, PID: 22516
10-30 20:03:07.967 22516 22568 E AndroidRuntime: java.lang.IllegalArgumentException: minValue=0,000000 > currentValue=-1,000000
10-30 20:03:07.967 22516 22568 E AndroidRuntime:        at android.service.controls.templates.RangeTemplate.validate(RangeTemplate.java:177)
10-30 20:03:07.967 22516 22568 E AndroidRuntime:        at android.service.controls.templates.RangeTemplate.<init>(RangeTemplate.java:83)
10-30 20:03:07.967 22516 22568 E AndroidRuntime:        at io.homeassistant.companion.android.controls.FanControl$Companion.createControl(FanControl.kt:52)
10-30 20:03:07.967 22516 22568 E AndroidRuntime:        at io.homeassistant.companion.android.controls.HaControlsProviderService$createPublisherForAllAvailable$1$1.invokeSuspend(HaControlsProviderService.kt:88)
10-30 20:03:07.967 22516 22568 E AndroidRuntime:        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
10-30 20:03:07.967 22516 22568 E AndroidRuntime:        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
10-30 20:03:07.967 22516 22568 E AndroidRuntime:        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
10-30 20:03:07.967 22516 22568 E AndroidRuntime:        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
10-30 20:03:07.967 22516 22568 E AndroidRuntime:        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
10-30 20:03:07.967 22516 22568 E AndroidRuntime:        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
10-30 20:03:07.970  1634 22913 I DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
10-30 20:03:07.971 22516 22568 I Process : Sending signal. PID: 22516 SIG: 9

Screenshot of problem:

Additional information:

bug

All 3 comments

What is the current value of the fan speed? it seems to be coming in as -1 is the fan off or something like that? we need some more data about the state and everything to fix this.

We should also catch the exception so we don't crash though too!

Ok, did some more testing, when fan is OFF, app crashes and these are the attributes of this entity in HA Dev tools: (NOTE: null in speed)

speed_list: Auto, Silent, Favorite, Fan
speed: null
model: zhimi.airpurifier.mb3
temperature: 22.3
humidity: 69
aqi: 10
mode: 0
filter_hours_used: 230
filter_life_remaining: 93
favorite_level: 10
child_lock: false
led: true
motor_speed: 0
average_aqi: 29
purify_volume: 15108
use_time: 803400
buzzer: false
led_brightness: 1
filter_rfid_product_id: 0:0:31:31
filter_rfid_tag: 80:66:58:da:f5:ee:4
filter_type: regular
fan_level: 1
friendly_name: Oczyszczacz
supported_features: 1
icon: mdi:air-purifier

When fan is ON, app works, these are the attributes in HA:

speed_list: Auto, Silent, Favorite, Fan
speed: Auto
model: zhimi.airpurifier.mb3
temperature: 22.3
humidity: 68
aqi: 10
mode: 0
filter_hours_used: 230
filter_life_remaining: 93
favorite_level: 10
child_lock: false
led: true
motor_speed: 388
average_aqi: 29
purify_volume: 15108
use_time: 803400
buzzer: false
led_brightness: 1
filter_rfid_product_id: 0:0:31:31
filter_rfid_tag: 80:66:58:da:f5:ee:4
filter_type: regular
fan_level: 1
friendly_name: Oczyszczacz
supported_features: 1
icon: mdi:air-purifier
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hypfer picture Hypfer  路  3Comments

N-Schaef picture N-Schaef  路  5Comments

simbesh picture simbesh  路  3Comments

Knoxie picture Knoxie  路  5Comments

andriej picture andriej  路  4Comments