Philips Android TV component


#143

I will add the new version and try the commands in few hours. Meanwhile here is the response from the /system call

{
"notifyChange": "http",
"menulanguage": "English",
"name": "Living room TV",
"country": "Romania",
"serialnumber_encrypted": "...",
"model_encrypted": "AR/NnwD3PqegI6MODoohu2+XxlVqMYiSkTo4xUXyOO4=\n",
"deviceid_encrypted": "...",
"nettvversion": "",
"epgsource": "one",
"api_version": {
    "Major": 6,
    "Minor": 1,
    "Patch": 0
},
"featuring": {
    "jsonfeatures": {
        "editfavorites": [
            "TVChannels",
            "SatChannels"
        ],
        "recordings": [
            "List",
            "Schedule",
            "Manage"
        ],
        "ambilight": [
            "LoungeLight",
            "Hue",
            "Ambilight"
        ],
        "menuitems": [
            "Setup_Menu"
        ],
        "textentry": [
            "context_based",
            "initial_string_available",
            "editor_info_available"
        ],
        "applications": [
            "TV_Apps",
            "TV_Games",
            "TV_Settings"
        ],
        "pointer": [
            "not_available"
        ],
        "inputkey": [
            "key"
        ],
        "activities": [
            "intent"
        ],
        "channels": [
            "preset_string"
        ],
        "mappings": [
            "server_mapping"
        ]
    },
    "systemfeatures": {
        "tvtype": "consumer",
        "content": [
            "dmr",
            "pvr"
        ],
        "tvsearch": "intent",
        "pairing_type": "digest_auth_pairing",
        "secured_transport": "true",
        "companion_screen": "true"
    }
}

}


#144

Thanks, i got rid of HASSOS and i installed hassbian. Now i wass able to pair my tv. I picked up the latest file from github. One hour old, so thans for being so active on this subject. It shows up now in the main view. I’m unable to controll the TV.
image

The logfile shows the following errors. Is there still a pairing issue?

Update for media_player.tv fails
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py”, line 221, in async_update_ha_state
await self.async_device_update()
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py”, line 349, in async_device_update
await self.hass.async_add_executor_job(self.update)
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/util/init.py”, line 324, in wrapper
result = method(*args, **kwargs)
File “/home/homeassistant/.homeassistant/custom_components/media_player/philips_2016.py”, line 226, in update
self._tv.update()
File “/home/homeassistant/.homeassistant/custom_components/media_player/philips_2016.py”, line 303, in update
self.getState()
File “/home/homeassistant/.homeassistant/custom_components/media_player/philips_2016.py”, line 373, in getState
r = self._getReq(‘powerstate’)
File “/home/homeassistant/.homeassistant/custom_components/media_player/philips_2016.py”, line 280, in _getReq
return json.loads(resp.text)
File “/usr/lib/python3.5/json/init.py”, line 319, in loads
return _default_decoder.decode(s)
File “/usr/lib/python3.5/json/decoder.py”, line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/lib/python3.5/json/decoder.py”, line 357, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Thank for the work on this.


#145

wow great work… still the on/off is not working completely correctly… but …really thank you sooo much.

Ik tried to make a script:

SBS6:
alias: SBS6
sequence:
- service: media_player.turn_on
data:
entity_id:media_player.philips_tv
- service: media_player.select_source
data:
entity_id: media_player.philips_tv
source: SBS6

But this isn’t working. Looks like de select source is not working?
do you know what is going wrong ?


#146

I installed the latest version and now it’s working. I think that it failed earlier because the TV was off for a long time and the state was reported as Idle. Also a few remarks, when i turn off the TV the state remains “idle” for 10 sec since the TV was turned off.

Also the set_volume_level method does not work for me.


#148

I think it has to do with the pictrogram before the channel? how can i achieve this ? somebody know how ??


#149

Very nice, on/off is working almost great for me. Sometimes it takes a while to register and sometimes pressing “ON” once doesn’t work, second time does then (I can probably improve on that somehow). Is this the problem you are having?

Exactly like I detailed in my post you have to add the emoji to tell if it is an app or TV channel.
You can just copy and paste it from here or somewhere else.
TV Channel: :tv: (television)
App: :iphone: (phone)

To type them in Windows use (Win + .) and type the name, but copying from here should work
Order:

  1. :tv: & :iphone:
  2. " " aka a space
  3. Name of the app/channel

You can also see it in the states section, just copy what is writting under source


#150

Very nice, this state is idle is now reported better :wink: And, yeah, that is the default wait time (actually 5sec) until the update method kicks in. In theory it would make sense to report the state directly as off. Hmm, will think about it. Could be problematic if the turning off fails.

Hmm it works on my end. I also barely changed anything there.
I would try a curl POST command and check if you can set it that way.
route: /audio/volume

{
  'current': targetlevel,
  'muted': False
}

targetlevel: A number from 0-60

Also your api seems to be almost the same as mine, I could not imagine any command working for me, not working for you.


#151

@nstrelow, is there any particular reason why you chose to use idle state rather than on?
I use universal media player and now it doesn’t work correctly at all after all changes re power state. As far as I understand idle for media player is considered “closer” to state off than on. Would it be better to use conventional states in case you decide to publish this component as an official?


#152

Don’t have that much experience with HA code but digging into your code it might be the fact that the TV it’s turned off and only when the next poll interval happens the state it’s updated.


#153

Doing a post on /audio/volume does not work for me :frowning:


#154

Kudos on getting Hassbian, gives you much more freedom.

This is still most likely an pairing issue or the command is not supported by your TV.

You could also try executing:

curl -X GET --digest --insecure -u user:password https://<ip address>:1926/6/system

Or even remove username and password, as this is not needed for access to /system
curl -X GET --digest --insecure https://<ip address>:1926/6/system

to check what nettvversion and what api version you have.

If you don’t have curl just install it with sudo apt-get install curl

But it is very probable that you still have some problem with the username and password. Double check that if you copied correctly


#155

Yeah that is exactly it. It will probably be better to set it to OFF right away. The calling of the “powerstate” command gives us certainty that it’s off. If the command fails, then we would show it as OFF for 10sec before the powerstate is updated and detects the TV has not been shut down.

This is the only though I have in mind right now. Setting the powerstate should actually not fail, so it could be save. If it fails, well you would have to wait 10 secs, before being able to turn it off again.

Very sad :sob: Probably nothing to be done about it. You can try finding other ways of APIs for setting the volume


#156

Also the media content type and media name it is set wrong in my case (app instead channel). The response from activities/current is

{
"component": {
    "packageName": "NA",
    "className": "NA"
}

}


#157

Well what are you playing? A TV channel? But probably this part of the API is also not working.
You can check the States Tab in HA. All the detected channels and applications should be there under source_list. I assume you have nothing there.
Very sad that this is not working for you.

I do have “NA” too, when I have no app opened and just some HDMI channel.


#158

Yes there is a very good reason. (correct me if I’m wrong)
Idle shows the player controller, e.g. the Play button.
An earlier version of somebody used STATE_ON, and that didn’t display the play button. As we have (currently) no way of checking if a video is playing or not, setting it to idle when on, enables resuming and pausing videos.

When using STATE_ON:
image


#159

@bogdanalexe90

What could also work is setting “WoWLAN” to on, I think this makes the api more available throughout the TV.
Or try launching the commands when the home menu is opened.


#160

Puh replying to so many people, I feel like Philips tech support.
I should ask them if they pay me for that :stuck_out_tongue:

Anyway, to sleep, have fun hacking around. Pull requests or also GitHub issues are always welcome.

But please add as much information as possible.
Great would be the /system GET call. That contains much useful information and shows directly if we have the same API.

Mine is 6.2.0


#161

I see your point, but are you sure that it is a correct logic for media player to have a pair of states off and idle? Sorry for my ignorance but what is the use of Play button for automation purposes? If the pair off/idle is correct than it must be something else is wrong with the code why it does not integrate with universal player correctly.
I had to go back to my old code since it is more important for me to be able to combine cast and other players in one and to automate on/off, mute/unmute and use other attributes rather than to play/stop youtube from HA.


#162

Yes i was playing a tv channel. In the Ha i can see the entire list of channels and qpps. More on that the activites/tv it’s returning the correct information for the current channel.


#163

So that means that activities/current shows NA
But you are playing a TV channel which is correctly displayed at activities/tv ?
When TV is playing it is showing org.droidtv… something when using activities/current. I could change that and if activities/current is NA, but activities/tv is playing something then use the info from that.