Philips Android TV component

It is interesting because it is the only thing I would need except on/off. Which TV model do you have? Did you use the developing androidtv component with some modifications to it?

Since the installation of this component, my tv turns on sometimes without any reason.
for example I wasn’t at home and looked at my home assistant instance and saw that my tv was on.

This also happened one time while we were sleeping.

Does someone else experience this?

HA 0.88 breaking the component.
Error loading custom_components.media_player.philips_2016. 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/philips_2016.py”, line 15, in <module> from homeassistant.components.media_player import (SUPPORT_STOP, SUPPORT_PLAY, SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, 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)

This should be the reason.

Unfortunately, Only changing the path to /config/custom_components/philips_2016/media_player.py does not solve the problem.

Did you try that too?

Always make sure you create at least an empty __init__.py file in that folder.

EDIT: Cann confirm that the component is broken in 0.88, even with that emty file added to the folder

Platform not found: media_player.philips_2016

after updating to 0.88 you need to change the imports in .py file at line 15

from homeassistant.components.media_player.const import (SUPPORT_STOP, SUPPORT_PLAY, SUPPORT_NEXT_TRACK, SUPPORT_PAUSE,
                                                   SUPPORT_PREVIOUS_TRACK, SUPPORT_VOLUME_SET, SUPPORT_TURN_OFF, SUPPORT_TURN_ON,
                                                   SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP, SUPPORT_SELECT_SOURCE)
from homeassistant.components.media_player import (PLATFORM_SCHEMA, MediaPlayerDevice)

SUPPORT_STOP, SUPPORT_PLAY, SUPPORT_NEXT_TRACK, SUPPORT_PAUSE,
_ SUPPORT_PREVIOUS_TRACK, SUPPORT_VOLUME_SET, SUPPORT_TURN_OFF, SUPPORT_TURN_ON,_
_ SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP, SUPPORT_SELECT_SOURCE_ must be imported from homeassistant.components.media_player.cons and PLATFORM_SCHEMA, MediaPlayerDevice must be imported from homeassistant.components.media_player

After changing it to this the configuration check takes forever (=doesn’t stop).

Can someone update the custom componets files :slight_smile:

1 Like

After changing the .py file and moving/renaming it works again for me. Thanks.

Feel free to make a PR to https://github.com/nstrelow/ha_philips_2016

I am currently busy, maybe I will time sometime this weekend to check it out.

what exactly did you change?

I renamed the .py file to media_player.py en moved it to its own folder philips_2016 under the custom_components. After that I copied the code from chelule and pasted it over the section which starts at line 15 in the .py file. It adds the bottom line and maybe changes the lines above it. After that it worked for me.

Repo is upgraded now with the correct fix. Thanks @fendrychl.
https://github.com/nstrelow/ha_philips_2016/blob/master/philips_2016.py

2 Likes

Works again, thanks!

in HASS 0.88.1 shows this.
Integrations need to be in their own folder. Change media_player/philips_2016.py to philips_2016/media_player.py. This will stop working soon.

I think I figured out what turns on my tv unpredictable.

Today I tried to turn on my tv using the component. As I mentioned before, this doesn’t work most of the times, because the tv is not online (no ping).
Approx. an hour after using the on button of the component (and not turning it on in the meantime with the normal remote) the TV turned on without an input.

@zauan So does the component wait for the tv to come online and than sends the turn_on command?
If yes, I think it would be better if the command gets canceled after some minutes (because than it makes no sense to send the command).

@occult simple turn arround the names of the folder and the .py-file and restart.

Thanks for telling, I looked now at the Great Migration and added a new philips_2016 folder accordingly.

Everyone who wants to prevent having the component stop at some future upgrade, should put the philips_2016 folder inside custom_component and delete the philips_2016.py under custom_component/media_player/.

Well the turn_on logic is not the best, as is noted in the Readme.
It tries multiple times, but should not keep trying for an hour.

Feel free to make it better :wink:

1 Like

I’m a little confused as there is a philips_2016 folder now with two files media_player.py and init.py

and another philips_2016.py file.
Do you keep this for users <0.88?

We only need the folder in our custom_components folder right?