Philips Android TV component


#164

Well it’s your choice. You can try optimizing the component for your purpose and submit a PR on GitHub.

I tell alexa resume/pause tv and it plays/pauses the thing that is currently playing :man_shrugging:

I have not looked into universal player and I have no idea why idle should make a difference to on.

Pls share your automations, I am curious what you can do.


#165

The simple answer is that the state of universal player is determined by states of child players as the following:
OFF_STATES = [STATE_IDLE, STATE_OFF, STATE_UNAVAILABLE]


#166

This would be too long, however, I also use Alexa to on/off Tv, automatically mute/unmute when there are voice notifications; pause audio system when TV is on; turn off/dim lights when films start playing etc. All this possible only when the media player reports the correct on/off state of course.


#167

He nstrelow,

yes, when the TV is off, also no network activity, it takes some time… or indeed I need to press the power on button a couple of times.

About the automation:
I already tried to use the picto.
As pictograms are not allowed (something to do with special chars)in the configuration.yaml this isn’t working for me… Do you know any workarround for this ?


#168

Ahahahhaha, damn I knew it would make problems.
But I feel like it is the cleanest way to show if app/channel in the UI.

I will probably introduce a way by either source: "app:Xxx" or with an additional field.

Thanks for reporting :wink:


#169

Well this makes perfect sense.
Also with the dimming, I think I saw an example with Kodi.
Most people want to dimm, only when they start playing something. Meaning if you are actually in the PLAY or PAUSE state, the lights will be dimmed. I find that a very neat and awesome automation.
Sadly with the Philips TV we have no way yet to check whether it is playing something.

And Universal Player defines ON as “something is being played on the media_player”
Edit: Or as STATE_ON, which is very weird. Probably because most players start with ON -> Play -> Idle, meaning you stopped watching your movie at Idle.

So we are kinda outta luck here.
Can you show me your basic universal player config? I will test that out and maybe also configure it for me. Maybe I’ll find a config solution or we then have the same problem. :man_shrugging:


#170

something else noticed: when the TV is off… my log file is filled with:

File “/usr/src/app/homeassistant/helpers/entity.py”, line 221, in async_update_ha_state
await self.async_device_update()
File “/usr/src/app/homeassistant/helpers/entity.py”, line 349, in async_device_update
await self.hass.async_add_executor_job(self.update)
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/src/app/homeassistant/util/init.py”, line 324, in wrapper
result = method(*args, **kwargs)
File “/config/custom_components/media_player/philips_2016.py”, line 230, in update
self._source = self._tv.app_name + ’ ’ + self._tv.channel_name
TypeError: unsupported operand type(s) for +: ‘NoneType’ and ‘str’


#171

Great, will tix


#172

Ahh found something else… when TV is off… en no network… after restart Home assistant initial state is unknown… :wink: It is not changed to OFF :wink:


#173

This might be true but my TV uses the API 6 here is the response from the /system call

{
"menulanguage": "German",
"name": "PhilipsTv",
"country": "Germany",
"serialnumber_encrypted": "",
"softwareversion_encrypted": "yPB1qeUECbsuB+PRHj2iJzD8JK0LEgs4XiGS\/GNzC2g=\n",
"model_encrypted": "ja4z\/OA4AimVFEMrsYExqauFfdPFobuItY1bjHAe45s=\n",
"deviceid_encrypted": "",
"nettvversion": "6.0.0",
"epgsource": "one",
"api_version": {
	"Major": 6,
	"Minor": 1,
	"Patch": 1
},
"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"]
	},
	"systemfeatures": {
		"tvtype": "consumer",
		"content": ["dmr", "dms_tad"],
		"tvsearch": "intent",
		"pairing_type": "digest_auth_pairing",
		"secured_transport": "true"
	}
}

}


#174

Here is my configuration of Universal Player:

media_player:
  - platform: universal
    name: TV
    children:
      - media_player.55pos900212
      - media_player.kodi
      - media_player.philips_tv
    commands:
      turn_on:
        service: switch.turn_on
        data:
          entity_id: switch.tv_on
      turn_off:
        service: media_player.turn_off
        data:
          entity_id: media_player.philips_tv
      volume_up:
        service: media_player.volume_up
        data:
          entity_id: media_player.philips_tv
      volume_down:
        service: media_player.volume_down
        data:
          entity_id: media_player.philips_tv
      volume_mute:
        service: media_player.volume_mute
        data:
          entity_id: media_player.philips_tv
          is_volume_muted: true
      volume_unmute:
        service: media_player.volume_mute
        data:
          entity_id: media_player.philips_tv
          is_volume_muted: true
      volume_set:
        service: media_player.volume_set
        data:
          entity_id: media_player.philips_tv
          volume_level: media_player.philips_tv|volume_level
    attributes:
      is_volume_muted: media_player.philips_tv|is_volume_muted
      volume_level: media_player.philips_tv|volume_level

Using it, I can actually check whether it is playing something on TV via Kodi (installed on the TV) or through cast and make my automation of lights. All these sources are shown in one player in frontend. Therefore, it is crucial to have a power state reported correctly. There is nothing odd how Universal player defines ON since Idle reserved only for those players which are always ON. This, however, cannot be the case for tv.


#175

@nstrelow: I guess i have version 6.1 The paring user and password that was returned was just copied and pasted. I tried the pairing again today and the pairing shows error_is success: Pairing completed. with a user and a password. But still HA is unable to communicate wit the TV.

This was returned by the get command:

“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”}}}[email protected]:~ $ ^C

Are there further steps i can take to solve this issue?


#176

@nstrelow: Thanks for helping me out. I now am able to communicate with the tv. Previously the tv was autodiscovered and i think that was blocking my connection from the custom component. The discovery was turned off, but the discovered component was still in HA (but not visible due to my group and view settings). So now i removed the discovered device in the configuration page and after the reboot it is working.
image

again thanks for the help. now i will try to make automations that turn on receiver, tv, correct source etc.


#177

Hmm, I do not think I can help you in any way. You can just try different curl commands and API path from the jointspace website. Maybe something else is working then. Or try resetting stuff?

You could also try the newest version, which is a more stable, but nothing related to your problem :confused:

I don’t like it, you even have the same API version as @mtol20.

I still think something has to be wrong with the pairing. Some wrong character or some pasting issue.


#178

Great, you got it working !!!


#179

Fix was uploaded


#180

Also fixed


#181

I could not reproduce it for myself, but I am trusting you and adding a special case.

Now when the the packageName is ‘NA’. it will try accessing channel information from /activities/tv and use that info.
If there is no info, then N/A - N/A is displayed, but it is still marked as channel.


#182

I see, yeah you are right. The default of the universal player has Idle as off state.
Using a state_template you could try to make it work with philips_tv being idle
Here is the example: https://www.home-assistant.io/components/media_player.universal/#kodi-cec-tv-control

Additionally I have added that the state is only idle, when an App is running. If you have Kodi running as app on the TV, this won’t help you. But it’s a start.

Feel free to change my code btw, you can just replace IDLE by ON


#183

Now I have. You can use the built-in script editor. Just go to Configuration->Scripts and add everything there.
If you do not want to do that you can use the escaped character:
:iphone: = \U0001F4F1
:tv: = \U0001F4FA

Example for YouTube in scripts.yaml:

'1541344661958':
  alias: Start YouTube
  sequence:
  - data:
      entity_id: media_player.tv
      source: "\U0001F4F1 YouTube"
    service: media_player.select_source