Hi,
could someone please tell me how I use the below as a script, as I would like to create a button that triggers an app or youtube video ect on my shield.
I’m currently on hassio and plan to install the newly created add-on
Hi,
could someone please tell me how I use the below as a script, as I would like to create a button that triggers an app or youtube video ect on my shield.
I’m currently on hassio and plan to install the newly created add-on
I managed to get it working, using hass.io + shield combination! So far so good, just 2 questions:
scene:
- name: playing
entities:
light.dining_1:
state: off
transition: 2
light.dining_2:
state: off
transition: 2
light.dining_3:
state: off
transition: 2
light.living_1:
state: on
transition: 2
brightness_pct: 3
light.living_2:
state: on
transition: 2
brightness_pct: 3
light.living_3:
state: on
transition: 2
brightness_pct: 3
light.living_penguin:
state: on
transition: 2
brightness_pct: 3
light.hallway_main:
state: off
transition: 3
- name: paused
entities:
light.living_1:
state: on
transition: 2
brightness_pct: 35
light.living_2:
state: on
transition: 2
brightness_pct: 35
light.living_3:
state: on
transition: 2
brightness_pct: 35
light.living_penguin:
state: on
transition: 2
brightness_pct: 60
light.dining_1:
state: on
transition: 2
brightness_pct: 35
light.dining_2:
state: on
transition: 2
brightness_pct: 35
light.dining_3:
state: on
transition: 2
brightness_pct: 35
And the automation:
- alias: "Media player paused/stopped"
initial_state: true
trigger:
- platform: state
entity_id: media_player.shieldtv
from: 'playing'
to: 'paused'
- platform: state
entity_id: media_player.shieldtv
from: 'playing'
to: 'idle'
- platform: state
entity_id: media_player.shieldtv
from: 'playing'
to: 'off'
condition:
condition: and
conditions:
- condition: template
value_template: "{{ states.sun.sun.attributes.elevation | int < 3 }}"
action:
service: scene.turn_on
entity_id: scene.paused
- alias: "Media player playing"
initial_state: true
trigger:
- platform: state
entity_id: media_player.shieldtv
from: 'paused'
to: 'playing'
- platform: state
entity_id: media_player.shieldtv
from: 'idle'
to: 'playing'
- platform: state
entity_id: media_player.shieldtv
from: 'off'
to: 'playing'
condition:
condition: and
conditions:
- condition: template
value_template: "{{ states.sun.sun.attributes.elevation | int < 3 }}"
action:
service: scene.turn_on
entity_id: scene.playing
Hi @phairplay, I’ve been working on something similar to what you requested. Here’s a screen shot of my Picture Elements Card: -
I drew the image in Powerpoint and then I’ve placed some invisible buttons over the images, so they behave like buttons. I’ve followed the documentation from adb addon and then the code for one of the buttons looks like this: -
- entity: input_boolean.androidtv
image: /local/RemoteButtonClear.png
style:
height: 22%
left: 17%
top: 15%
width: 10%
tap_action:
action: call-service
service: media_player.androidtv_key
service_data:
entity_id: media_player.android_tv
key: KEYCODE_DPAD_UP
type: image
I found this: -
Hope it helps
This is so cool! Do you have your config on github or are you willing to share the lovelace yaml code used to make this?
Hi bobokun,
There’s really not much going on with code. Each button is basically the same. I’ve drawn the entire picture in Powerpoint and then saved it as a png. I’ve found Powerpoint to be useful because of all the built in icons and the alignment tools are very useful. I created a coloured button (RemoteButton.png), which is just a square shape that I saved as its own png file, and then positioned that over each of the icons. When I was happy with the placement I swapped the coloured button for an invisible one (RemoteButtonClear.png). When I say invisible, I just changed the shape in Powerpoint, so it had no outline or fill, then saved that as a png file. All these images are in the www folder in config. The DPAD cursor type buttons use the code I shared above and the intent buttons (for apps etc) use this code: -
- entity: input_boolean.androidtv
image: /local/RemoteButtonClear.png
style:
height: 22%
left: 41%
top: 34%
width: 10%
tap_action:
action: call-service
service: media_player.androidtv_intent
service_data:
entity_id: media_player.android_tv
intent: '-n org.xbmc.kodi/.Splash'
The difference is the type of service that is called and ‘key’ is replaced with ‘intent’. You need to follow all the steps of adding the adb addon: -
You also have to add the androidtv.py file to the relevant location and create the media_player entity.
The input_boolean entity is a dummy that allows you to have an element on this card. Everything is actually controlled from the service calls.
Hope that helps.
Does anybody know how to turn on / off Ambilight + Hue on a philips android TV using this component?
I tried to use it with Philips TV 55POS900212 and experience the same issue when it correctly shows which app is running but it doesn’t change idle status to playing when the app is actually playing. I can provide details if it helps to debug it.
Hello everyone,
I have the mibox and the components wich works well.
But the original remote is broken so I replace it by USB remote.
Activate USB debugging in the mibox completely deactivate all remote connected to the mibox.
An idea ?
You should use your smartphone to control it.
Search for Android TV Remote control. Works perfectly for me.
thanks but my wife will never accept that
fix for 0.88.0:
the include at line 33
from homeassistant.components.media_player import (
DOMAIN, MediaPlayerDevice, PLATFORM_SCHEMA, SUPPORT_NEXT_TRACK,
SUPPORT_PAUSE, SUPPORT_PLAY,
SUPPORT_PREVIOUS_TRACK, SUPPORT_STOP, SUPPORT_TURN_OFF,
SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP)
becomes:
from homeassistant.components.media_player import ( DOMAIN,
MediaPlayerDevice, PLATFORM_SCHEMA)
from homeassistant.components.media_player.const import (
SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PLAY,
SUPPORT_PREVIOUS_TRACK, SUPPORT_STOP, SUPPORT_TURN_OFF,
SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP)
Hello I’m a Hass.io user and tried setting this up in version 0.87.1. I get the following error even though the ADB addon is showing connectivity to my AndroidTV. Any ideas anyone? I’ve tried deleting the deps folder and letting it rebuild. I’m using the latest androidtv.py file (.0.0.7) so at a loss at the moment.
2019-02-20 17:40:42 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform androidtv
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/local/lib/python3.6/asyncio/tasks.py”, line 358, in wait_for
return fut.result()
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/media_player/androidtv.py”, line 196, in setup_platform
adb_server_port=config[CONF_ADB_SERVER_PORT])
File “/config/deps/lib/python3.6/site-packages/androidtv/init.py”, line 249, in init
self.properties = self.device_info()
File “/config/deps/lib/python3.6/site-packages/androidtv/init.py”, line 441, in device_info
properties = self.adb_shell(‘getprop’)
File “/config/deps/lib/python3.6/site-packages/androidtv/init.py”, line 272, in _adb_shell_pure_python_adb
return self._adb_device.shell(cmd)
File “/config/deps/lib/python3.6/site-packages/adb_messenger/command/transport/init.py”, line 20, in shell
conn = self.create_connection(timeout=timeout)
File “/config/deps/lib/python3.6/site-packages/adb_messenger/device.py”, line 45, in create_connection
self.transport(conn)
File “/config/deps/lib/python3.6/site-packages/adb_messenger/command/transport/init.py”, line 15, in transport
connection.send(cmd)
File “/config/deps/lib/python3.6/site-packages/adb_messenger/connection.py”, line 77, in send
return self._check_status()
File “/config/deps/lib/python3.6/site-packages/adb_messenger/connection.py”, line 83, in _check_status
raise RuntimeError(“ERROR: {} {}”.format(repr(recv), error))
RuntimeError: ERROR: ‘FAIL’ 000edevice offline
Got this in 0.88
2019-02-21 10:18:55 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.media_player.androidtv. Make sure all dependencies are installed
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/homeassistant/loader.py", line 147, in _load_file
module = importlib.import_module(path)
File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/config/custom_components/media_player/androidtv.py", line 33, in <module>
from homeassistant.components.media_player import (
ImportError: cannot import name 'SUPPORT_TURN_OFF' from 'homeassistant.components.media_player' (/usr/local/lib/python3.7/site-packages/homeassistant/components/media_player/__init__.py)
2019-02-21 10:18:55 ERROR (MainThread) [homeassistant.loader] Unable to find platform androidtv
I guess is not yet fixed in github
go up a few messages, I wrote a simple fix. and yes it’s not committed yet =)
Is this simple fix available? I keep getting “Platform not found: media_player.androidtv” after updating to 0.88.0
I hope this migration guide helps: https://developers.home-assistant.io/blog/2019/02/19/the-great-migration.html