Example for configuration.yaml Philips Android TV component
How to receive user and password to your tv Philips Android TV component
Ipt2207,
it´s just like above said:
media_player:
- platform: philips_2016
name: phTV
host: 192.x.x.x
username: yourusername
password: yourpassword
as for the xml renaming and folder placing it is correct and also,
the name of the file you end up with has to match the platform name.
For the settings above the file must be renamed to philips_2016.py
Where I can get username and password?
Post nr 1 in this thread.
The steps to access this API are:
- Get a pairing code from Philips ( https://github.com/suborb/philips_android_tv/blob/master/philips.py#L30 )
- After this, you will receive an username and password
- Use this username and password to access the jointspace API ( using /6/ instead of /1/ and HTTPS instead of HTTP )
Yes I see that, but don’t understnd?
I go to link in 1. but only see code from philips.py?
If anyone here is interested, I have created a custom light component for the Ambilights of Philips TV’s and opened a new topic for it, if you need any help with it, or have any suggestions for more features, I will be over there
Has anyone already figured out how to use the “Wake on LAN” for post 2016 Philips Android TV’s?
I’m using the following configuration but it doesn’t work (yet):
wake_on_lan:
switch:
- platform: wake_on_lan
mac_address: "aa:bb:cc:dd:ee:ff"
The WoWLAN function is switched on in my TV’s settings, can’t find a WoLAN setting
Thanks for the info.
I’m only interested in getting the Philips remote control app working for basic channel changing, volume, mouse and keyboard. With everything else I’m way out of my depth here.
OK Everyone after hours and hours and hours of learning,
I have successfully used this post to connect my Philips TV (Model: 43PUT6801/79 Man: June 2017) to my Home Assistant installation.
Frontend
Source Select
Achieved Results
With this custom component I am able to connect the TV via a network connection, and am able to view what station it is on and what channel it is, I can also control the volume and power on/off on the TV as well as change the channel source to any other live TV station.
Challenges
Some of the biggest challenges I faced when attempting this was, initially, that I had no knowledge of Python or Linux really for that matter.
My System
My current setup is a Raspberry Pi 3B running Hassio and Home assistant (HA) version 0.78 at the time of writing this.
Steps and Sources of Information:
I was interested in having my Philips TV communicate with Home Assistant.
This was a exciting feature as my current setup has xBox One, ps4, and kodi- libreelec media players sending what is playing to HA. The only device I had one way communication with was the Philips TV, as I was using an IR blaster to control this. Using a "Broadlink IR RM3 mini" and using this home assistant component. Using this I was able to control the TV as if I was using a remote control. However this was not telling my media player to current state of the TV which all other media devices were able to do. There had to be a solution.
See below for my Broadlink media player configuration.yaml before getting this custom component to work:
Media_player:
- platform: broadlink
name: Philips IR Control
host: 10.0.4.122
mac: '78:0f:77:47:90:9e'
ircodes_ini: 'broadlink_media_codes/philips.ini'
ping_host: 10.0.4.123
I tried the original joint space API with the Philips TV but my Tv was not supported as I purchased it 2017 and it is Android TV. Found this link in feature requests Philips Android TV component
Reading through this forum I noticed many people were having similar issues with various 2016+ Philips TVs.
The following steps provide this to work.
Gaining a username and password from the Philips 2016+ TV (Android)
- Read through the forums and found a Python script to retrieve username and password from the TV.
Script from Post number 2 https://github.com/suborb/philips_android_tv
This script was a little bit confusing for me at first, as it is called philips.py and the custom component Python script is called philips2016.py. from post 2 Hope this clarifies the two different script names.
2 Different Scripts
The Pairing Script
The script by Suborb on github philips.py from post 1 gives the access to retrieve TV credentials from the Philips TV.
- Clone git the script to the Linux system ( see here for detailed info about git clone ).
git clone https://github.com/mveken/home_assistant.git
- Change the directory to philips_android_tv
cd philips_android_tv
-
Make sure the TV is on and is connected to a network
-
Find the IP address of the TV using whatever method you need to e.g. router, Fing, etc
-
Run the Python script
python philips.py --host TVHOSTIP_ADDRESS_HERE pair
-
Check the TV for the code that appears on the bottom right hand corner
and use this code for the next step -
Go to a web browser and enter: http://YOURIPADDRESS:1926
-
Enter the code as directed
You will be presented with a username and password similar to this:
Save these details for later.
The Custom Component Media Player Python Script
The script philips_2016.py from martijnv worked best for my setup
the custom component media player and should be copied into the HA directory:
/config/custom_components/media_player
.
Add Custom Media Player to Configuration.yaml
These details will be used in your configuration.yaml file when entering the media player information.
-
Set up media player in configuration.yaml (Philips 2016+)
media_player: - platform: philips_2016 name: Philips TV host: 192.168.x.x username: user from pairing password: pass from pairing
Save your configuration.yaml and reboot the system.
- After system has rebooted check your states and locate the media player you just created
I reason for 2 of the same player is that I have a universal media player also that mimics the active mediaplayer in use see this link
Hope this helps.
I had this working on my Philips 55PUS6412, but after upgrading home assistant to version 0.80.0, I am getting some errors from the py script
“File “/config/custom_components/media_player/philips_2016.py”, line 103, in volume_level
return self._volume / self._max_volume”
Anyone else having issues in the new HA version
I did some digging around, I really wanted to be able to launch apps.
Apparently someone figured it out after I failed (I even forgot that):
Here it is: https://github.com/suborb/philips_android_tv/issues/5#issuecomment-370509253
I may try to build a component incorporating everything found here.
Should have checked out this thread way earlier, this is a goldmine of great ways to control that philips tv
Just a quick overview of things I got working (using the scripts already shared here):
- Play and Pause working (There is no PlayPause key (at least for me), so I had to check the actual state and set it to STATE_PLAYING or STATE_PAUSED)
- Apps as sources instead of channels (since I don’t watch TV and have no sources except Google Play Movies trailers, I wanted to get that working)
Here is the updated philips_2016.py
Be aware that channel switching is not supported anymore in favor of app switching.
I will add a config option later, so you can choose (or maybe enable both)
Constantly made improvements today for the app switching.
Now the current app is shown in the source select box
i tried the new philips_2016.py and getting errors in the log:
Unable to serialize to JSON: Object of type ‘dict_keys’ is not JSON serializable {‘id’: 2, ‘type’: ‘event’, ‘event’: {‘event_type’: ‘state_changed’, ‘data’: {‘entity_id’: ‘media_player.tvbeneden’, ‘old_state’: <state media_player.tvbeneden=playing; volume_level=0.26666666666666666, is_volume_muted=False, media_content_type=app, media_title=TV, app_name=TV, source_list=dict_keys([‘Help’, ‘Play Store’, ‘YouTube’, ‘Prime Video’, ‘Play Muziek’, ‘Play Games’, ‘Play Films’, ‘Netflix’, ‘Internet Browser’, ‘QuickSupport’, ‘TV-gids’, ‘Opnames’, ‘Bronnen’, ‘Media’, ‘Demomenu’, ‘Appgalerij’, ‘Topselectie’, ‘TV’, ‘Spotify’, ‘Tellybean’, ‘Notifications for Android TV’, ‘ARTE’, ‘Dailymotion’, ‘RTL XL’, ‘NPO’, ‘TV5Monde’, ‘Pathé Thuis’, ‘KIJK’, ‘FOX Sports NL’, ‘Megogo HD’, ‘Deezer’, ‘France24’, ‘Divan.TV’, ‘Social TV’, ‘GameTreeTV GOLD’, ‘Videoland’, ‘Filmbox Live’, ‘MovieMAX Online’, ‘Toon Goggles’, ‘Fishing TV’, ‘VLC’, ‘Instellingen’, ‘Zenders instellen’, ‘Zo kunt u…’, ‘Draadloos en netwerken’, ‘Apps beheren’, ‘Software bijwerken’]), friendly_name=TVbeneden, supported_features=23997 @ 2018-10-24T21:41:18.384159+02:00>, ‘new_state’: <state media_player.tvbeneden=paused; volume_level=0.2833333333333333, is_volume_muted=False, media_content_type=app, media_title=TV, app_name=TV, source_list=dict_keys([‘Help’, ‘Play Store’, ‘YouTube’, ‘Prime Video’, ‘Play Muziek’, ‘Play Games’, ‘Play Films’, ‘Netflix’, ‘Internet Browser’, ‘QuickSupport’, ‘TV-gids’, ‘Opnames’, ‘Bronnen’, ‘Media’, ‘Demomenu’, ‘Appgalerij’, ‘Topselectie’, ‘TV’, ‘Spotify’, ‘Tellybean’, ‘Notifications for Android TV’, ‘ARTE’, ‘Dailymotion’, ‘RTL XL’, ‘NPO’, ‘TV5Monde’, ‘Pathé Thuis’, ‘KIJK’, ‘FOX Sports NL’, ‘Megogo HD’, ‘Deezer’, ‘France24’, ‘Divan.TV’, ‘Social TV’, ‘GameTreeTV GOLD’, ‘Videoland’, ‘Filmbox Live’, ‘MovieMAX Online’, ‘Toon Goggles’, ‘Fishing TV’, ‘VLC’, ‘Instellingen’, ‘Zenders instellen’, ‘Zo kunt u…’, ‘Draadloos en netwerken’, ‘Apps beheren’, ‘Software bijwerken’]), …
21:43 components/websocket_api/http.py (ERROR)
Error executing query: Object of type ‘dict_keys’ is not JSON serializable
@Emilio_Emile Sorry, fixed that an hour ago with: https://github.com/nstrelow/ha_philips_2016/commit/c94735f66dc8c15a0b1fdd78be61e2eceb3d2ba5
Please update the custom_component
Does turn on work for you without the wake-on lan feature?
No, I have not touched the logic concerning the turn_on and off functions.
Basically on/off just sends the “Standby” key, which is not working if the TV is off some time. So WOL is needed.
A workaround I use:
TV is attached to wifi socket. I turn this on/off to turn on the TV. When the TV is on and the power is cut off (so wifi socket goes off), when turning it gets power again it is already on.
Basically I do not put it into standby, but cut the power.
Apps are now sorted in newest version and a bug fix when the no app is opened:
Thank you @nstrelow for these improvements. It is a great addition to the component.
I’ve noticed that you chose to have standby state only if tv reports it. However, when tv goes into sleeping mode after some time, it will be offline. It causes the state of tv showing as ‘playing’ as per your code. Would it be better to use it as the following:
if self._StateC == 'On':
self._state = STATE_ON
else:
self._state = STATE_OFF
I use universal media player to combine on/off functionality with broadlink IR switch, so the IR switch only turns the tv on but the ‘off’ uses the media player functionality. It gives better control of the factual state of the tv as well as it is recommended to keep OLED tv in standby mode rather than completely disconnect it from power.