Find a file
Alfiegerner e12c6e38b1
Small BLE Transmitter enhancement, handle Bluetooth state changes better, improve robustness (#1384)
* First cut add BLE beacon as new sensor.

* Lint issues, also using hardcoded strings for state.

* Fixes and small tidies following review.

* Add command_ble_transmitter to MessagingService.kt, to control BLE Transmitter from HA notifications.

* Make description more specific for settings.

* Return if sensor not enabled

* Spaced.

* Command turn on for transmitter should stop it first, as state could be incorrect on Bluetooth being disabled.

* Don't attempt to transmit if BT is off, and include that information in the state.

* Update app/src/main/java/io/homeassistant/companion/android/sensors/BluetoothSensorManager.kt

Co-authored-by: Justin Bassett <bassett.justint@gmail.com>

* Add 2 new settings:
  - Power transmitter values between high and ultra low.  Defaults to ultra low, should help with Battery concerns
  - A setting which allows the sensor to be turned on by default when the Enable all toggle is turned on.  This is off by default, users have to actively seek out this sensor to turn it on.

* Add battery warning to description.

* Fix build - stray merge comma deletion.

* Fix small description text error.

* Fix left notification when high accuracy mode was disabled (#1366)

Some points which may fix this issue
* Make notification objects static
* Use ServiceCompat for stopForeground
* Additionally call cancel to remove notification

* Bump some app dependencies (#1374)

* Add BLE ibeacon transmitter as sensor to allow room presence. (#1343)

* First cut add BLE beacon as new sensor.

* Lint issues, also using hardcoded strings for state.

* Fixes and small tidies following review.

* Add command_ble_transmitter to MessagingService.kt, to control BLE Transmitter from HA notifications.

* Make description more specific for settings.

* Return if sensor not enabled

* Spaced.

* Command turn on for transmitter should stop it first, as state could be incorrect on Bluetooth being disabled.

* Don't attempt to transmit if BT is off, and include that information in the state.

* Update app/src/main/java/io/homeassistant/companion/android/sensors/BluetoothSensorManager.kt

Co-authored-by: Justin Bassett <bassett.justint@gmail.com>

* Add 2 new settings:
  - Power transmitter values between high and ultra low.  Defaults to ultra low, should help with Battery concerns
  - A setting which allows the sensor to be turned on by default when the Enable all toggle is turned on.  This is off by default, users have to actively seek out this sensor to turn it on.

* Add battery warning to description.

* Fix build - stray merge comma deletion.

* Fix small description text error.

Co-authored-by: Justin Bassett <bassett.justint@gmail.com>

* And fix service fields being added too many times (#1377)

* Improve robustness when BT is turned on and off. Also, tidy code, keep sense of when device parameters have changed in one place.

Co-authored-by: Justin Bassett <bassett.justint@gmail.com>
Co-authored-by: chriss158 <edgi@arcor.de>
Co-authored-by: Daniel Shokouhi <dshokouhi@gmail.com>
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2021-03-01 09:29:49 -05:00
.github Add some logging to release note generator. (#1370) 2021-02-21 22:03:16 -05:00
app Small BLE Transmitter enhancement, handle Bluetooth state changes better, improve robustness (#1384) 2021-03-01 09:29:49 -05:00
buildSrc Add BLE ibeacon transmitter as sensor to allow room presence. (#1343) 2021-02-25 21:09:37 -05:00
common And fix service fields being added too many times (#1377) 2021-02-25 21:15:05 -05:00
gradle/wrapper Update to Gradle 6.8 (#1300) 2021-01-19 10:36:38 -05:00
wear Feature/wear publishing (#1264) 2020-12-27 22:04:37 -05:00
.gitignore Feature/wear publishing (#1264) 2020-12-27 22:04:37 -05:00
build.gradle.kts Update to Gradle 6.8 (#1300) 2021-01-19 10:36:38 -05:00
CLA.md Add required documents 2019-04-01 22:52:24 -07:00
CODE_OF_CONDUCT.md Update Code of Conduct to 2.0 (#603) 2020-05-26 09:10:31 +02:00
gradle.properties Update distribution plugin. (#1079) 2020-10-20 09:34:45 -04:00
gradlew Remove redundant buildscript declaration (#1029) 2020-10-11 13:38:46 -04:00
gradlew.bat Remove redundant buildscript declaration (#1029) 2020-10-11 13:38:46 -04:00
LICENSE.md Add required documents 2019-04-01 22:52:24 -07:00
README.md Allow overriding PUSH_URL and RATE_LIMIT_URL in gradle.properties (#1032) 2020-10-11 14:14:49 -04:00
settings.gradle.kts Update to Gradle 6.8 (#1300) 2021-01-19 10:36:38 -05:00

📱 Home Assistant Companion for Android Beta Deploy

Documentation

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

  • io.homeassistant.companion.android

  • io.homeassistant.companion.android.debug

  • io.homeassistant.companion.android.minimal

  • io.homeassistant.companion.android.minimal.debug

  • 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:

  • KEYSTORE_PASSWORD

  • KEYSTORE_ALIAS

  • KEYSTORE_ALIAS_PASSWORD

  • Run the build using gradlew build from command line.

  • If the build is successful, you can run the app by doing the following: click Run -> Run 'app'

  • 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.

Push Notifications

If you want to work on push notifications or use a development build with push notifications, please go the server side code HERE and deploy it to your firebase project. Once you have your androidV1 URL to the deployed service, set it in to your ${GRADLE_USER_HOME}/gradle.properties file, e.g.:

homeAssistantAndroidPushUrl=https://mydomain.cloudfunctions.net/androidV1

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

homeAssistantAndroidRateLimitUrl=https://mydomain.cloudfunctions.net/checkRateLimits

App Flavors

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.

Quality

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

./gradlew ktlintCheck

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:

./gradlew ktlintFormat

Translating

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

Generating a release to production

  • Create a new release with the name and tag in the {MAJOR}.{MINOR}.{PATCH} format
  • Steal the release notes from the latest beta build
  • This will cause a tag to be added to the project and the Production Deploy Workflow will handle the rest
  • Note: Only the first 500 characters of the release notes get set in the Google Play release