domoticz / domoticz-android

Domoticz Client Application for Android Devices
104 stars 70 forks source link

Use Android 11 feature: Control external devices #599

Closed galadril closed 3 years ago

galadril commented 3 years ago

The Quick Access Device Controls feature, available starting in Android 11, allows the user to quickly view and control external devices such as lights, thermostats, and cameras from the Android power menu. Device aggregators (for example, Google Home) and third-party vendor apps can provide devices for display in this space. This guide shows you how to add support for device controls to your control app.

afbeelding

To add this support, create and declare a ControlsProviderService, create the controls your app supports based on predefined control types, and then create publishers for these controls.

https://www.androidcentral.com/android-11-heres-whats-new-power-menu-and-device-controls https://developer.android.com/preview/features/device-control

galadril commented 3 years ago

611 (worked on setting Android 11 as target sdk)

galadril commented 3 years ago

I cant continue on this feature, because i cant test this on emulators.. I don't own an Android 11 devices yet....

See this issue on Google: https://issuetracker.google.com/issues/168973367

galadril commented 3 years ago

Would be working on this feature on this branch https://github.com/domoticz/domoticz-android/tree/external-control-menu

galadril commented 3 years ago

Working on the new feature!! image

galadril commented 3 years ago

@ofalvai I have a question for you on implementing the new External Controls Service.

Im trying to implement this, but im sometimes loosing controls when adding them to the list of controls for the power menu: https://www.youtube.com/watch?v=JQ7whWCnnSo

As you can see on the video, the last control that i added disappeared right after closing and opening the control center. There are no errors whatsoever in the logs.. It also shows that the newly added control was removed:

ControlsProviderService: Creating publishers for 4
ControlsProviderService: Adding stateful for device: Woonkamer Lampen | with control id 3002
ControlsProviderService: Adding stateful for device: Keuken Lampen | with control id 3003
ControlsProviderService: Adding stateful for device: Lampen | with control id 3005
ControlsProviderService: Adding stateful for device: Spot 1 (Bank) | with control id 1655
ControlsProviderService: Done processing

ControlsProviderService: Creating publishers for 3
ControlsProviderService: Adding stateful for device: Woonkamer Lampen | with control id 3002
ControlsProviderService: Adding stateful for device: Keuken Lampen | with control id 3003
ControlsProviderService: Adding stateful for device: Lampen | with control id 3005
ControlsProviderService: Done processing

This is the control service: https://github.com/domoticz/domoticz-android/blob/external-control-menu/app/src/main/java/nl/hnogames/domoticz/service/CustomControlService.java

I dont know if you also encountered this issue?? And maybe solved it??

galadril commented 3 years ago

Now in beta!

galadril commented 3 years ago

Finally implemented this new feature

android11feature