Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that we default to expected values to meet requirements for android power menu #1088

Merged
merged 2 commits into from Oct 22, 2020

Conversation

dshokouhi
Copy link
Member

Should fix the following sentry error:

java.lang.IllegalArgumentException: stepValue=0,000000 <= 0
    at android.service.controls.templates.RangeTemplate.validate(RangeTemplate.java:184)
    at android.service.controls.templates.RangeTemplate.<init>(RangeTemplate.java:83)
    at io.homeassistant.companion.android.controls.DefaultSliderControl$Companion.createControl(DefaultSliderControl.kt:37)
    at io.homeassistant.companion.android.controls.HaControlsProviderService$createPublisherForAllAvailable$1$1.invokeSuspend(HaControlsProviderService.kt:85)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

According to the input_number code we don't need to adjust much as they already take care of most requirements:

https://developer.android.com/reference/android/service/controls/templates/RangeTemplate#RangeTemplate(java.lang.String,%20float,%20float,%20float,%20float,%20java.lang.CharSequence)

https://github.com/home-assistant/core/blob/dev/homeassistant/components/input_number/__init__.py#L53

https://github.com/home-assistant/core/blob/dev/homeassistant/components/input_number/__init__.py#L68

@dshokouhi
Copy link
Member Author

It seems the issue here is that when an entity was restored to unavailable all attributes come in as null since they do not exist and that is why the defaults matter for input number as we set them based on current attributes

@JBassett JBassett merged commit 1fbde71 into home-assistant:master Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants