Home Assistant custom component for the newer (2016+) Philips Android TVs
I am using the icons 📱 and 📺 to distinguish between apps and tv channels. IMO this looks nice in UI, and you need to include the icon, a space and then the name in your automations.
Example of source: "📱 Kodi"
You can also copy what you want from States pages under the property source_list of your TV.
Example using the built-in script editor. Go to Configuration->Scripts.
YAML does not support the emojis. So if you do not want to use the script editor, you can use the escaped character:
- 📱 = \U0001F4F1
- 📺 = \U0001F4FA
Example for YouTube in scripts.yaml:
youtube:
alias: YouTube
sequence:
- data:
entity_id: media_player.tv
source: "\U0001F4F1 YouTube"
service: media_player.select_source
First you need to pair the TV. This gets you a username and a password to be used in the configuration of the component.
- Clone the repo with pairing script:
git clone https://github.com/suborb/philips_android_tv
- Install the requirements (for Python 3, so you may need to use pip3):
pip3 install -r requirements.txt
- Execute pairing. A PIN code will appear on your TV. Input that in your terminal
python3 philips.py --host <IP of TV> pair
Now you will have a username and password you can use in your HA configuration.
- Create directories
custom_components/philips_android_tv/
in the config directory. - Starting with 0.91: Add the media_player.py init.py and manifest.json files from this repo under
<config_dir>/custom_components/philips_android_tv/media_player.py
etc. DISCLAIMER: The custom component and its folder needed to be renamed as only characters and underscore are permitted for component names. The numbers 2016 are not allowed anymore. See (https://developers.home-assistant.io/docs/en/creating_integration_manifest.html#domain) - Add the following to your configuration.yaml using your username and password from the pairing process. You can leave out the mac, if you do not care using HA to turn your TV on/off.
media_player:
- platform: philips_android_tv
name: TV
host: 192.168.1.111
mac: aa:aa:aa:aa:aa:aa
username: xxxxx
password: xxxxx
- Restart home-assistant
Essentially wake-on-lan wakes up the API part of the TV. Then the TV is able to receive a command to set the power state to on. Currently this isn't completely reliable , but can be improved a lot, when programmed properly (e.g. a nice way to wait for the TV to start the API and check if it's online).
You have to enable WoWLAN under Settings->Wireless&Networks->Wired&Wifi->Switch on with Wi-Fi (WoWLAN) And add the Wifi MAC address to your config.
I believe this can also work using the LAN MAC, but I am running it currently with the WoWLAN feature.
I am always happy to see PRs and will merge or comment on them.
I would wish to make a real component of this. But it needs a lot of work to get there. I think doing every API call async will be needed. Also it would be awesome to automate setting up the component (discovery), such as paring and finding the MAC addresses. Then it should be possible to use feature such as the entity registery. Or even combining this with the custom Ambilight component into a device registery. In the end a pyhton module doing all the API communication would also be awesome.
- Philips Android TV custom component HA thread: https://community.home-assistant.io/t/philips-android-tv-component/17749
- Philips TV Ambilight thread: https://community.home-assistant.io/t/philips-android-tv-ambilights-light-component/67754