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

Prevent null values for BLE measured power, also allow negative values in case entire field is cleared out #2158

Merged
merged 3 commits into from Jan 18, 2022

Conversation

dshokouhi
Copy link
Member

Summary

Fixes the following sentry error by defaulting to the correct value instead of crashing. I also noticed if a user clears out the field they can no longer add back a negative number so changed the field only for this setting as its the only one that expects a default value.

java.lang.NumberFormatException: For input string: ""
    at java.lang.Integer.parseInt(Integer.java:627)
    at java.lang.Integer.parseInt(Integer.java:650)
    at io.homeassistant.companion.android.sensors.BluetoothSensorManager.updateBLEDevice(BluetoothSensorManager.kt:169)
    at io.homeassistant.companion.android.sensors.BluetoothSensorManager.updateBLESensor(BluetoothSensorManager.kt:195)
    at io.homeassistant.companion.android.sensors.BluetoothSensorManager.requestSensorUpdate(BluetoothSensorManager.kt:109)
    at io.homeassistant.companion.android.sensors.SensorDetailFragment.refreshSensorData$lambda-17$lambda-16$lambda-12(SensorDetailFragment.kt:260)
    at io.homeassistant.companion.android.sensors.SensorDetailFragment.$r8$lambda$k1ldwhuKc_YUTyjQuSUk_5iHWwg
    at io.homeassistant.companion.android.sensors.SensorDetailFragment$$ExternalSyntheticLambda4.onPreferenceChange
    at androidx.preference.Preference.callChangeListener(Preference.java:1118)
    at androidx.preference.ListPreferenceDialogFragmentCompat.onDialogClosed(ListPreferenceDialogFragmentCompat.java:107)
    at androidx.preference.PreferenceDialogFragmentCompat.onDismiss(PreferenceDialogFragmentCompat.java:265)
    at androidx.fragment.app.DialogFragment$3.onDismiss(DialogFragment.java:132)
    at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1424)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:257)
    at android.app.ActivityThread.main(ActivityThread.java:8307)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)

Screenshots

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

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