home assistant приложение для android

Home assistant приложение для android

? Home Assistant Companion for Android badge

If you are looking for documentation around the companion applications check out the Home Assistant Companion Documentation. This will provide you instructions on using the applications.

Setup App Development Environment

Download and install Android Studio

Download / clone this repository to a folder on your computer

Create a Firebase project at Firebase Console

Create four Android apps, with following package names

Now download the google-services.json file and put it in the home-assistant-Android/app folder. This file contains the configuration of the whole project (all the four applications).

You can also use the mock services file instead of generating your own The file should contain client IDs for all packages listed above for debugging to work properly. If you do not generate your own file push notification will never work

Start Android Studio, open your source code folder and check if the Gradle build will be successful using Build/Make Module «App». You might have to install the right Android SDK via Tools/SDK Manager first.

Create keystore containing keypair for debug application signing. In Android Studio: Menu/Build/Generate signed APK, then use a button to create new keystore. Remember the passwords and key alias

Set environmental variables used in app/build.gradle.kts :

Run the build using gradlew build from command line.

Connect your phone or create a new virtual device following on screen instruction

If you get stuck while setting up your own environment, you can ask questions in the #devs_mobile_apps channel on Discord.

You can also define the rate limit function URL, e.g.:

The Android app has both a full flavor that uses Google Play Services to offer features like location tracking and notifications. There is also a minimal flavor that does not require Google Play Services and can be found in the releases section. The minimal flavor does not have location tracking or notifications.

Testing Dev Releases

We are using Github Actions to perform continuous integration both by unit testing, deploying dev releases to Play Store Beta and final releases to the Play Store when we release. To help test out a specific feature/fixes users can find the APK on the Actions page for each pull request, this debug APK can be installed side-by-side the production or beta builds.

We are using ktlint as our linter. You can run a check locally on your machine with:

This commands runs on our CI to check if your PR passes all tests. So we strongly recommend running it before committing.

To run a check with an auto-format:

The project currently uses lokalise to translate the application. If you are interested in helping translate go to the link and click start translating!

Источник

Android TV

The androidtv platform allows you to control an Android TV device or Amazon Fire TV device.

When setting up this integration, it is recommended that you do NOT use an ADB server and instead use the built-in Python ADB implementation. This simplifies the setup and makes it easier to troubleshoot issues. If there are stability issues with this approach, then you may wish to try using an ADB server. See the ADB Setup section for more information.

Device preparation

To set up your device, you will need to find its IP address and enable ADB debugging. For Android TV devices, please consult the documentation for your device.

For Fire TV devices, the instructions are as follows:

Configuration

Configuration Variables

The IP address for your Android TV / Fire TV device.

The friendly name of the device.

The port for your Android TV / Fire TV device.

The path to your adbkey file; if not provided, Home Assistant will generate a key for you (if necessary).

The IP address of the ADB server. If this is provided, the integration will utilize an ADB server to communicate with the device.

The port for the ADB server.

Whether or not to retrieve the running apps as the list of sources.

A dictionary where the keys are app IDs and the values are app names that will be displayed in the UI; see example below. If a name is not provided, the app will never be shown in the sources list. (These app names are configured in the backend package and do not need to be included in your configuration.)

If this is true, then only the apps you specify in the apps configuration parameter and those specified in the backend library will be shown in the sources list.

A dictionary whose keys are app IDs and whose values are lists of state detection rules; see the section Custom State Detection for more info.

An ADB shell command that will override the default turn_on command.

An ADB shell command that will override the default turn_off command.

Determines if album art should be pulled from what is shown onscreen.

Full Configuration

ADB Setup

This integration works by sending ADB commands to your Android TV / Fire TV device. There are two ways to accomplish this.

1. Python ADB Implementation

The default approach is to connect to your device using the adb-shell Python package. As of Home Assistant 0.101, if a key is needed for authentication and it is not provided by the adbkey configuration option, then Home Assistant will generate a key for you.

Prior to Home Assistant 0.101, this approach did not work well for newer devices. Efforts have been made to resolve these issues, but if you experience problems then you should use the ADB server option.

2. ADB Server

The second option is to use an ADB server to connect to your Android TV and Fire TV devices.

Using this approach, Home Assistant will send the ADB commands to the server, which will then send them to the Android TV / Fire TV device and report back to Home Assistant. To use this option, add the adb_server_ip option to your configuration. If you are running the server on the same machine as Home Assistant, you can use 127.0.0.1 for this value.

ADB Troubleshooting

If the setup for your Android TV or Fire TV device fails, then there is probably an issue with your ADB connection. Here are some possible causes.

You have the wrong IP address for the device.

ADB is not enabled on your device.

You are already connected to the Android TV / Fire TV via ADB from another device. Only one device can be connected, so disconnect the other device, restart the Android TV / Fire TV (for good measure), and then restart Home Assistant.

You need to approve the ADB connection; see the note in the ADB Setup section above.

Some Android TV devices (e.g., Philips TVs running Android TV) only accept the initial ADB connection request over their Wi-Fi interface. If you have the TV wired, you need to connect it to Wi-Fi and try the initial connection again. Once the authentication has been granted via Wi-Fi, you can connect to the TV over the wired interface as well.

If your device drops off WiFi, breaking the ADB connection and causing the entity to become unavailable in Home Assistant, you could install a wake lock utility (such as Wakelock) to prevent this from happening. Some users have reported this problem with Xiaomi Mi Box devices.

If you are using the Python ADB implementation approach, as mentioned above, there may be some issues with newer devices. In this case, you should use the ADB server approach instead.

Services

media_player.select_source

androidtv.adb_command

The service androidtv.adb_command allows you to send either keys or ADB shell commands to your Android TV / Fire TV device. If there is any output, it will be stored in the ‘adb_response’ attribute (i.e., state_attr(‘media_player.android_tv_living_room’, ‘adb_response’) in a template) and logged at the INFO level.

Service data attribute Optional Description
entity_id no Name(s) of Android TV / Fire TV entities.
command no Either a key command or an ADB shell command.

In an action of your automation setup it could look like this:

Available key commands include:

The full list of key commands can be found here.

You can also use the command GET_PROPERTIES to retrieve the properties used by Home Assistant to update the device’s state. These will be stored in the media player’s ‘adb_response’ attribute and logged at the INFO level. This information can be used to help improve state detection in the backend androidtv package, and also to define your own custom state detection rules.

A list of various intents can be found here.

androidtv.learn_sendevent (for faster ADB commands)

When sending commands like UP, DOWN, HOME, etc. via ADB, the device can be slow to respond. The problem isn’t ADB, but rather the Android command input that is used to perform those actions. A faster way to send these commands is using the Android sendevent command. The challenge is that these commands are device-specific. To assist users in learning commands for their device, the Android TV integration provides the androidtv.learn_sendevent service. Its usage is as follows:

As an example, a service call in a script could be changed from this:

androidtv.download and androidtv.upload

You can use the androidtv.download service to download a file from your Android TV / Fire TV device to your Home Assistant instance.

Service data attribute Optional Description
entity_id no Name of Android TV / Fire TV entity.
device_path no The filepath on the Android TV / Fire TV device.
local_path no The filepath on your Home Assistant instance.

Similarly, you can use the androidtv.upload service to upload a file from Home Assistant instance to Android TV / Fire TV devices.

Service data attribute Optional Description
entity_id no Name(s) of Android TV / Fire TV entities.
device_path no The filepath on the Android TV / Fire TV device.
local_path no The filepath on your Home Assistant instance.

Custom State Detection

The solution to this problem is the state_detection_rules configuration parameter, which allows you to provide your own rules for state detection. The keys are app IDs, and the values are lists of rules that are evaluated in order. Valid rules are:

Источник

Понравилась статья? Поделить с друзьями:
Добавить комментарий
  • Как сделать успешный бизнес на ритуальных услугах
  • Выездной кейтеринг в России
  • Риски бизнеса: без чего не обойтись на пути к успеху
  • home assistant мобильное приложение
  • hold формы неправильного глагола