Philips Android TV component


#184

Made more changes, mostly bugfixes
You can see all changes here: https://github.com/nstrelow/ha_philips_2016/commits/master
Download: https://github.com/nstrelow/ha_philips_2016/blob/master/philips_2016.py

Have fun :smiley:


#185

I tried the template before but it didn’t work, now I figured out the reason. As for Kodi as an app, I didn’t understand what you mean since I use Kodi media player as a separate component included as a child player in Universal Player. I also don’t have a “normal” tv channels, it goes via tv-box from my provider, so only apps run on my TV.
I, of course, can change your code. It seems to me that it’s better to do everything right from the beginning :wink:


#186

I can’t reproduce the “NA” behaviour anymore. Now i get
{
“component”: {
“packageName”: “org.droidtv.playtv”,
“className”: “org.droidtv.playtv.PlayTvActivity”
}
}

Also i saw that you updated the code to force the state to off after turning off. I saw in other components that they are forcing an update instead of setting state to something that may be wrong. I think it’s a bit more safe like this.


#187

Pairing is fine but the url for the channellist is different i found the new url but i must miss something becouse my change doesent work

def getChannels(self):
    r = self._getReq('channeldb/tv/channelLists/{allcab}')
    if r:
        self.channels = dict(sorted({chn['name']:chn for chn in r['Channel']}.items(), key=lambda a: a[0].upper()))
        self.channel_source_list = ['📺 ' + channelName for channelName in self.channels.keys()]

the result if i run the command manually is like this i have not enoug python kwnoledge to fix this myself i hope someone can help me

{
"version": 6,
"id": "allcab",
"operator": "KDG",
"installCountry": "Germany",
"listType": "TV",
"medium": "cable",
"Channel": [{
	"ccid": 924,
	"preset": 1,
	"name": "Das Erste HD",
	"onId": 0,
	"tsid": 1051,
	"sid": 11100,
	"type": "DVB_C",
	"serviceType": "audio_video",
	"logoVersion": "_id"
}, {
	"ccid": 923,
	"preset": 2,
	"name": "ZDF HD",
	"onId": 0,
	"tsid": 1079,
	"sid": 11110,
	"type": "DVB_C",
	"serviceType": "audio_video",
	"logoVersion": "_id"
}, {
	"ccid": 922,
	"preset": 3,
	"name": "NDR FS HH HD",
	"onId": 0,
	"tsid": 1101,
	"sid": 10329,
	"type": "DVB_C",
	"serviceType": "audio_video",
	"logoVersion": "_id"
}

#189

Very good idea, should have thought about that myself. Will change


#190

I hope you redraw because you got it working. Congrats :smiley:


#191

HMMMMMM, that character seems very broken: '📺 ’

But is is also very possible, that you have also another command for changing the channel. I do not know.

You can play around with it and when you get it working, I will try integrating it.

There are great many ways of learning python and it’s a simple, good scripting language IMO
E.g.: https://www.learnpython.org/


#192

Yes… I first thougt… WHy is is not working!!
after looking ten times to my code I saw that I missed a spacebar in a Channel name :wink: :slight_smile: :slight_smile:


#193

Hello,
I was not able to exceute pairning script.Im connected with putty.Step one clone from git hub was sucessfull ,but then Philips folder doesnt exist and also when i try just run script it say that python doesnt exists.Can you please tell me how can i run that script? Thanks.


#194

@Mesiee It sound like your using HassOS like i did at first. This is the default on the getting started page of HA. With that image it seems impossble to install required software and get the pairing done. Most people on this forum are not using the closed HassOS but something where they have more control like Hassbian. I hope this will help you like it helped me.


#195

Is it possible to create an automation based on the source selection off het tv? I tried this:

> - id: '1541846576897'
>   alias: Netflix TV audio
>   trigger:
>   - entity_id: media_player.tv
>     platform: state
>     to: 'media_title: Netflix'
>   condition: []
>   action:
>   - data:
>       entity_id: media_player.av_receiver
>       source: TV Audio
>     service: media_player.select_source

So is a state trigger possible for other states then on, off and idle? An example of this would help me.


#196

To access other properties than state, I am using a template value

{{ state_attr('media_player.tv', 'media_title') == 'Netflix'}}

Here: https://www.home-assistant.io/docs/automation/trigger/#template-trigger


#197

so… after a week of testing with this component… it look like it is working great.
Maybe you can give it to the HA team… and implement it in the original code ?


#198

Is it possible to use this addon with Hassio?


#199

Everything you need to know is inside this thread.

Because I am nice:
This is currently a custom component you need to manually copy into config/custom_components/media_player.
You also need to pair your TV, get a username/password and put that into your config.


#200

Thanks for replying. I have read this thread from the beginning and I have issues with python script. I have installed libraries from requirements file, however, whenever I try to run philips.py script I receive following error:

 Traceback (most recent call last):
  File "philips.py", line 6, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

#201

Try the Custom deps deployment Hassio add-on. And pip install requests


#202

Thanks for help! I found what was wrong - for some reason with Python 3.7 I was not able to execute the script. However, I got it working with Python 2.7.
Short tutorial for not so techy persons (like me) Windows users :slight_smile:

  1. Download and install Python 2.7 (Google it)
  2. Download and install Microsoft Visual C++ Build Tools
  3. During the installation hit Advanced button and mark:
    Compile .py files to byte code after installation.
  4. Extract the component.
  5. Open the folder and on the file explorer’s top right select File > Open Windows PowerShell > Open Windows PowerShell as Administrator
  6. In the command line type:
    pip install -r requirements.txt
  7. If the pip installation was executed with no errors in the same command line type:
    python philips.py --host 192.168.xx.xx pair
  8. The script should be executed

#203

I have a new philips TV without android.

It exposes the API on TCP/1925 and does NOT require pairing and HTTP authentication.

I’ve taken the nice philips_2016.py and ambilights.py and removed the HTTP auth in the POST and GET reqs. Seems to half work - I still have work to do on this API but the TCP port 1925 STOPs responding after a while.

I see in the philips_2016.py there is a fix for this by using the same HTTP connection as there is a bug after 100 SSL connections.
This doesnt seem to help with my setup though, like i say its http not ssl.
Need to deplete the TV’s capacitors and refil to get the port open again.

Any advise would be great


#204

After pairing TV and adding credentials to my configuration.yaml file I receive such error. Did I do something wrong?

INFO:homeassistant.util.package:Attempting install of colorlog==3.1.4
Testing configuration at /config
ERROR:homeassistant.scripts.check_config:BURB
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 207, in check
    res['components'] = check_ha_config_file(hass)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 372, in check_ha_config_file
    platform = loader.get_platform(hass, domain, p_name)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/loader.py", line 60, in get_platform
    return get_component(hass, PLATFORM_FORMAT.format(domain, platform))
  File "/usr/local/lib/python3.6/site-packages/homeassistant/loader.py", line 92, in get_component
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_components/media_player/philips_2016.py", line 7
    <!DOCTYPE html>
    ^
SyntaxError: invalid syntax
Fatal error while loading config: invalid syntax (philips_2016.py, line 7)
Failed config
  General Errors: 
    - invalid syntax (philips_2016.py, line 7)
Successful config (partial)