@k2v1n58 wrote:
We are many to use tablet or Android devices for our Home Assistant.
Thanks to its development console, Android allows us to access and modify the parameters (hardware and software). Here’s how to access to them and take control of your Android device:
ADB over TCP
The first step is to active the Android Debug Bridge (ADB) over TCP
See Enabling developer mode on your device from this page https://github.com/hassio-addons/addon-adb.
If the Network debugging is not available on your device, follow tutorials on internet or connect your device to your computer and with the terminal set this command:adb tcpip 5555
Install ADB server
Follow instructions here: https://github.com/hassio-addons/addon-adb/Configure Home Assistant
Follow instructions here: https://www.home-assistant.io/integrations/androidtv/
Then, restart and a new media_player should appearTests and use
From the androidtv.adb_command service, we can try the different commands. GET commands will display properties in device’s state.
I give some example here that can be use in automations and scripts:
Get screen brightness
entity_id: media_player.xxx
command: settings get system screen_brightnessSet screen brightness
entity_id: media_player.xxx
command: settings put system screen_brightness {value}The screen backlight brightness between 0 and 255
Get screen brightness mode
entity_id: media_player.xxx
command: settings get system screen_brightness_modeSet screen brightness
entity_id: media_player.xxx
command: settings put system screen_brightness_modeSupported values are 0 for manual and 1 for automatic
Get stay on while plugged in
entity_id: media_player.xxx
command: global get system stay_on_while_plugged_inSet stay on while plugged in
entity_id: media_player.xxx
command: global put system stay_on_while_plugged_in {value}Supported values are:
0
to never stay on while plugged inBatteryManager#BATTERY_PLUGGED_AC
to stay on for AC chargerBatteryManager#BATTERY_PLUGGED_USB
to stay on for USB chargerBatteryManager#BATTERY_PLUGGED_WIRELESS
to stay on for wireless chargerTurn off the screen by simulating a press on the Power Button
entity_id: media_player.xxx
command: input keyevent 26Start and kill an app (example with Home Assistant Companion for Android)
entity_id: media_player.xxx
command: am force-stop io.homeassistant.companion.androidentity_id: media_player.xxx
command: monkey -p io.homeassistant.companion.android 1Turn off the screen in case of long press on the Hue remote:
alias: Screens off after long press trigger: - entity_id: remote.remote platform: state to: 4_hold_up condition: - condition: template value_template: '{{ states("media_player.xxx") != "off" }}' # check current screen status action: - data: command: input keyevent 26 entity_id: media_player.xxx service: androidtv.adb_command
All the ADB commands are accessible from developers Android website (https://developer.android.com/reference/android/provider/Settings.Global).
ADB over TCP offers unlimited possibilities (and for free). You can modify and read all hardware and software properties, and also simulate pressing buttons.
Posts: 2
Participants: 2