Page 1 of 1

ADB Android TV

Posted: Saturday 21 March 2020 21:46
by OedzesG
Hallo everyone..


for HomeAssistant there is a plugin available to get the status of Android TV.

Code: Select all

https://www.home-assistant.io/integrations/androidtv/
Is there a possibility to get this done in Domoticz?

I use an Nvidia Shield with multiple apps and would like to know the playback status, for example to dim the lamps.

Thx in advance.

Re: ADB Android TV

Posted: Monday 23 March 2020 7:29
by skybehind
+1

Re: ADB Android TV

Posted: Monday 23 March 2020 20:15
by OedzesG
+1

Until someone has arranged it (if anyone wants to build it) there is a way to send the data to Domoticz by HA using a json call.
I still had a PI somewhere and decided to test with HA this weekend. The disadvantage is that HA has to run next to Domoticz, but it works until, of course, someone makes it suitable for Domoticz.

Here is an example of how you can set this up in HA.

configuration.yaml:

Code: Select all


media_player:
  - platform: androidtv
    host: 192.168.1.36
    name: "NVidia Shield"
    adb_server_ip: 127.0.0.1
    adb_server_port: 5037
    state_detection_rules:
      'com.plexapp.android':
        - 'paused':
            'media_session_state': 3  # this indentation is important!
            'wake_lock_size': 1       # this indentation is important!
      
rest_command:
  shield_playing:
    url: 'http://192.168.1.11:8080/json.htm?type=command&param=switchlight&idx=63&switchcmd=On'
  shield_pause:
    url: 'http://192.168.1.11:8080/json.htm?type=command&param=switchlight&idx=63&switchcmd=Off'
    

automations.yaml: (testing for Netflix)

Code: Select all


- id: '1584909354303'
  alias: 'Netflix playback: "playing" '
  description: 'Update Domoticz UV if Netflix is playing on Shield Android TV '
  trigger:
  - entity_id: media_player.nvidia_shield
    platform: state
    to: playing
  condition:
  - condition: template
    value_template: '{{ states.media_player.nvidia_shield.attributes.app_name == "Netflix"
      }}'
  action:
  - data: {}
    service: rest_command.shield_playing
- id: '1584909833684'
  alias: 'Netflix playback: "paused" '
  description: 'Update Domoticz UV if Netflix is paused on Shield Android TV '
  trigger:
  - entity_id: media_player.nvidia_shield
    platform: state
    to: paused
  condition:
  - condition: template
    value_template: '{{ states.media_player.nvidia_shield.attributes.app_name == "Netflix"
      }}'
  action:
  - data: {}
    service: rest_command.shield_pause


Re: ADB Android TV

Posted: Thursday 09 July 2020 11:32
by jelleeelco
Hi,

I'm currently trying to switch the lights on/off using the Harmony-Span server, that can read the buttons pressed in an activity and update domoticz. But, within Netflix one can play/pauze using a variety of buttons (play, pauze, stop, select) so it's nearly impossible to have it work perfectly (unless ppl in the household REMEMBER that only play/pauze button will actuall trigger the ligths).

It would be great if one can read the status of the Shield directly, just as with the Kodi plugin where it reads Video / Pauze. I guess doing this via HA works for now, I just had one question if you don't mind.

Does this work for ALL the apps on the Shield, independend of what app? So i.e. Netflix, Disney, Amazon, Kodi?

Many thanks in advance,
Cheers
Jelle

Re: ADB Android TV

Posted: Saturday 25 March 2023 20:59
by lwolf
OedzesG wrote: Monday 23 March 2020 20:15 Until someone has arranged it (if anyone wants to build it) there is a way to send the data to Domoticz by HA using a json call.
I still had a PI somewhere and decided to test with HA this weekend. The disadvantage is that HA has to run next to Domoticz, but it works until, of course, someone makes it suitable for Domoticz.
Basic AndroidTV python plugin:
https://github.com/enesbcs/domo-androidtv