Introducing the Custom ADB Sensor for Home Assistant πŸš€

Hello, I would like to announce my latest custom component: ADB Sensor, a simple and flexible integration designed to enhance your Home Assistant setup for those of you using ADB (androidtv integration). If you have an Android TV, Fire TV, or any other ADB-compatible device, this component opens up a world of possibilities for creating better custom sensors tailored to your needs. :tada:


What is the ADB Sensor?

The ADB Sensor is a Home Assistant custom component that lets you monitor various aspects of your ADB-compatible devices by running ADB commands and displaying the results as sensor states. Whether you want to track the current app running on your Fire TV, monitor device states, or parse custom data, this integration has you covered.


Key Features

  • :hammer_and_wrench: Custom ADB Commands: Create sensors based on any ADB command output.
  • :robot: Integration with androidtv.adb_command: Seamlessly works with the existing Home Assistant service for ADB commands.
  • :memo: Value Templates: Customize and parse the output to fit your requirements.
  • :male_detective: Debugging Made Easy: Access raw ADB responses in the sensor attributes.

Example Use Case: Detecting the Current App running on your device

sensor:
  - platform: adb_sensor
    name: Fire TV Current App
    adb_entity_id: media_player.fire_tv_192_168_1_202
    adb_command: "dumpsys window | grep mCurrentFocus"
    value_template: >
      {% for line in value.split('\n') %}
      {% if "mCurrentFocus=" in line %}
      {{ line.split('=')[-1].split('{')[-1].split('}')[0].split()[-1] }}
      {% endif %}
      {% endfor %}

The sensor will dynamically update with the name of the currently open app on your Android device.

Here is the GitHub repo: GitHub - jkfran/custom-adb-sensor: A flexible Home Assistant custom component that provides configurable sensors to extract and monitor data from ADB commands, with an example for detecting the current app on Android TV or Fire TV.

I hope this can be useful. Thank you!

1 Like