-
-
Notifications
You must be signed in to change notification settings - Fork 683
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
Add notification command for turning the flashlight on/off #4766
Add notification command for turning the flashlight on/off #4766
Conversation
we actually request the phone permission for one specific intent I think you can use the same method. Take user to webview, then they grant the permission and try again.
this would require HA core changes, we dont have any controllable entities and have not discussed about how it should work. Think this probably requires an arch discussion. |
I created a PR in the documentation repository: home-assistant/companion.home-assistant#1131 |
app/src/main/java/io/homeassistant/companion/android/notifications/MessagingManager.kt
Outdated
Show resolved
Hide resolved
… the notification command will be posted as a regular notification on < Android M devices
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please submit a PR to the mobile app FCM repo adding the new command to the list commands so it can be excluded from the rate limit?
https://github.com/home-assistant/mobile-apps-fcm-push/blob/main/functions/android.js#L70-L74
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested debug APK and works as expected
Summary
I added the
command_flashlight
notification command. It accepts two values in thecommand
field:turn_on
orturn_off
.Currently, my implementation only supports API 23 and above, while the app has
minSdkVersion = 21
. The main reason is mylazinesslack of time, and because the Camera2 API is available starting from API 23, and I haven't found a trivial...Compat
solution. If someone mentions needing this on API 21-22, it can be implemented as a separate feature request. Please let me know if this approach is OK for you.The PR is marked as a draft because I still have to implement requesting the Camera permission, but I first wanted to ask for your advice on it. The problem is that in
MessagingManager
only so-called "special permissions" are being requested, and there are no runtime permissions, and it would require anActivity
. I thought of adding anotherregisterForActivityResult(ActivityResultContracts.RequestPermission())
inBaseActivity
and makingBaseActivity
subscribe to an event-likeFlow
from a singleton class, which would trigger a permission request, andMessagingManager
could trigger this event. WDYT?Related feature request: #1606
Screenshots
N/A
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#1131
Any other notes
Future improvement possibilities:
command: toggle
binary_sensor
representing the current state of the torch (maybe even alight
entity?)