-
-
Notifications
You must be signed in to change notification settings - Fork 680
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
Allow measured power to be updated via notification command #4546
Allow measured power to be updated via notification command #4546
Conversation
Why have it behave differently, instead of always ignoring it (which is the default behavior with notification commands for invalid values)? |
Added a check to make sure that doesn't happen, should be good now :) |
I'm not sure I follow. (data[DeviceCommandData.BLE_MEASURED_POWER]?.toIntOrNull() ?: BluetoothSensorManager.DEFAULT_MEASURED_POWER_AT_1M) < 0 will still use a different value if it cannot be parsed to an int, instead of rejecting/ignoring the command. |
That was why i added the check before to capture any other bad value, added
|
But why not do And even if there is a bad (positive) value, it is still set as you don't change the value in line 160? data[NotificationData.COMMAND] == DeviceCommandData.BLE_SET_MEASURED_POWER &&
(
data[DeviceCommandData.BLE_MEASURED_POWER].toIntOrNull() != null && data[DeviceCommandData.BLE_MEASURED_POWER]?.toInt() < 0
) |
I see my comment is inconsistent with current behavior - invalid changed to something valid for UUID/major/minor. Lines 144 to 145 in 485a842
But that is the exception to the default which ignores the command if invalid ( Line 68 in 485a842
|
Your check is simpler and for some reason I did not consider it, lets go with that as its easier to read :) |
Summary
Implements: #3290
example service call:
The field is validated that its not blank and that it is a negative number
Screenshots
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#1086
Any other notes
FCM PR: home-assistant/mobile-apps-fcm-push#150