esphome-api-android
Android helpers for esphome-api: mDNS discovery. Home Assistant finds the device on its own.
Android helpers for esphome-api. For now that's EspHomeMdns, which
advertises the device over mDNS with Android's NsdManager, so Home Assistant discovers it on its
own. Package dev.glassworks.esphome.android, MIT licensed. Depending on this module also brings in
esphome-api.
val mdns = EspHomeMdns(context, board = "my-tablet") // board: optional `board` TXT record
server.start()
mdns.start(identity, server)
// Encryption state changed (HA set a key): re-advertise so HA knows a key is now required.
server.onKeyActivated = { mdns.stop(); mdns.start(identity, server) }
It publishes <name>._esphomelib._tcp with the TXT records ESPHome uses: friendly_name,
version, mac, network, optionally board, and the encryption records. Those are
api_encryption when a key is set, or api_encryption_supported plus api_provisioning=zero-psk
while HA can still provision one.
What it advertises, next to what ESPHome does, is in esphome-api's comparison with ESPHome.
Gradle
On Maven Central as dev.glassworks:esphome-api-android (changelog).
repositories { mavenCentral() }
dependencies {
implementation("dev.glassworks:esphome-api-android:0.1.0")
}
An Android library (AAR), minSdk 23 (Android 6). It brings in dev.glassworks:esphome-api. Your app
can compile against any compileSdk from 23 up. A Kotlin build needs Kotlin 2.0 or newer; a Java build
needs Java 17 (so compileSdk 30 or newer). The module's manifest adds
INTERNET, which the API server's socket needs.