Philips Smart TVs also with SAPHI OS

Currently the Philips TV integration uses the jointspace API which is only avaliable for a selection of Philips TVs running Android.

There is a second product branch running a more streamlined OS called SAPHI OS. These devices do not have Jointspace. However, if you search for pylips on github, you’ll find a python library which uses a reverse engineered API for both product branches. This could help enable a more wider target range for connecting philips tvs to HA. I’d love to have this to check the TVs status and dim my Hue lights accordingly.

Also have a Philips 754 with ambilight. Would be awesome if there’s a way to control the ambilight.

Integration would be awesome.
For a workaround, i`ve managed to get some basic automations running using a broadlink device to emulate the remote control, which includes (at least for the phillips 55OLED 794 series) dedicated buttons for netflix & Rakuten TV.

I`ve scoured the internet for a long time to truly get the smart aspect of the smart tv integrated in hassio but this was the most workable for now. Maybe this helps someone :slight_smile:

1 Like

There is the https://github.com/eslavnov/pylips which seems to work for my 43PUS6754/12 but would love to see it integration into HA.

1 Like

Can you guys dump the system endpoint of your saphi tv:s here?

Should be on any of these endpoints.

https://hostname:1926/6/system
http://hostname:1925/6/system
http://hostname:1925/5/system
http://hostname:1925/1/system
http://hostname:1925/system

Ps. You may want to redact serial number.

{
	"menulanguage": "English",
	"name": "MySexyTV",
	"country": "Netherlands",
	"serialnumber_encrypted": "K2kseVsmQFgkd15gKkJ+anroyY/BtXi7YxRx5ZmHDbY=",
	"softwareversion_encrypted": "K2kseVsmQFgkd15gKkJ+amueMe3DHAmDQ8d/R/pbq751fehPhcnVDYODjenVeAIP",
	"model_encrypted": "K2kseVsmQFgkd15gKkJ+apER1659GfrMjbN8kkfeyFo=",
	"deviceid_encrypted": "",
	"nettvversion": "",
	"epgsource": "no_epg",
	"api_version": {
		"Major": 6,
		"Minor": 1,
		"Patch": 0
	},
	"featuring": {
		"jsonfeatures": {
			"recordings": [
				"List",
				"Schedule",
				"Manage"
			],
			"ambilight": [
				"Hue",
				"HueStreaming",
				"Ambilight"
			],
			"textentry": [
				"context_based",
				"initial_string_available"
			],
			"inputkey": [
				"key",
				"unicode"
			],
			"pointer": [
				"context_based"
			],
			"activities": [
				"browser"
			]
		},
		"systemfeatures": {
			"tvtype": "consumer",
			"content": [
				"dmr"
			],
			"pairing_type": "none",
			"companion_screen": true,
			"os_type": "Linux"
		}
	}
}

{
	"menulanguage": "Dutch",
	"name": "50PUS6804/12",
	"country": "Netherlands",
	"serialnumber_encrypted": "alotofnumbersandletters",
	"softwareversion_encrypted": "K2kseVsmQFgkd15gKkJ+amueMe3DHAmDQ8d/R/pbq75SQ3mIJ7KzpbV8Z0lz4DAg",
	"model_encrypted": "K2kseVsmQFgkd15gKkJ+ajj14v1k18xtrm2jX61cQ9Y=",
	"deviceid_encrypted": "Alotofnumbersandletters",
	"nettvversion": "4.6.0.1",
	"epgsource": "no_epg",
	"api_version": {
		"Major": 6,
		"Minor": 1,
		"Patch": 0
	},
	"featuring": {
		"jsonfeatures": {
			"recordings": [
				"List",
				"Schedule",
				"Manage"
			],
			"ambilight": [
				"Hue",
				"HueStreaming",
				"Ambilight"
			],
			"textentry": [
				"context_based",
				"initial_string_available"
			],
			"inputkey": [
				"key",
				"unicode"
			],
			"pointer": [
				"context_based"
			],
			"activities": [
				"browser"
			]
		},
		"systemfeatures": {
			"tvtype": "consumer",
			"content": [
				"dmr"
			],
			"pairing_type": "none",
			"companion_screen": true,
			"os_type": "Linux"
		}
	}
}

http://hostname:1925/6/system

{
	"menulanguage": "Russian",
	"name": "Super_TV",
	"country": "Latvia",
	"serialnumber_encrypted": "K2kseVsmQFgkd15gKkdsfJ+ag6KPTV92QvGzy1lSbQkHSM=",
	"softwareversion_encrypted": "K2kseVsmQFgkd15gKkJ+asHgx51A+805kJDAB27sdfo7y+5ZGXrvba7qfNXaXKWmNaP",
	"model_encrypted": "K2kseVsmQFgkdds15gKkJ+alA3I1Xu1e464rnQibd0kcg=",
	"deviceid_encrypted": "K2kseVsmQFgkd15gsdfKkJ+aiQF83Vdgl6gOuy/N+hCs1g=",
	"nettvversion": "4.6.0.1",
	"epgsource": "broadcast",
	"api_version": {
		"Major": 6,
		"Minor": 1,
		"Patch": 0
	},
	"featuring": {
		"jsonfeatures": {
			"recordings": [
				"List",
				"Schedule",
				"Manage"
			],
			"textentry": [
				"context_based",
				"initial_string_available"
			],
			"inputkey": [
				"key",
				"unicode"
			],
			"pointer": [
				"context_based"
			],
			"activities": [
				"browser"
			]
		},
		"systemfeatures": {
			"tvtype": "consumer",
			"content": [
				"dmr"
			],
			"pairing_type": "none",
			"os_type": "Linux"
		}
	}
}v

Perfect! Thanks guys.

Does: http://hostname:1925/6/powerstate
Or: https://hostname:1926/6/powerstate
work?

Does it require authentication?

It does work for me without authentication on the http-adress but the TV must be on.

Cool: that mean: https://github.com/home-assistant/core/pull/46422 aught to work.

Source selection wont nor applications. But if you can test it and report results maybe i can get some things fixed.

So some more endpoints i’d like the output from:
http://hostname:1925/6/channeldb/tv
http://hostname:1925/6/applications
http://hostname:1925/6/activities/browser
http://hostname:1925/6/activities/current
http://hostname:1925/6/activities/tv

Also if you could grab, while playing some tv channel, while on some hdmi source, while at home menu i would be good.
http://hostname:1925/6/context

http://192.168.1.23:1925/6/system

	"menulanguage": "Unknown",
	"name": "55OLED754/12",
	"country": "United Kingdom",
	"serialnumber_encrypted": "Kzwse1shQCMkJV4mKj9+PmIm/5c2Yp0eU02ewk0DDOU=",
	"softwareversion_encrypted": "K2kseVsmQFgkd15gKkJ+amueMe3DHAmDQ8d/R/pbq75SQ3mIJ7KzpbV8Z0lz4DAg",
	"model_encrypted": "K2kseVsmQFgkd15gKkJ+aoVYVbm8KvlYgfINFpkYHig=",
	"deviceid_encrypted": "K2kseVsmQFgkd15gKkJ+aln8JJwmspYJ3Qd3Xry+lVE=",
	"nettvversion": "4.6.0.1",
	"epgsource": "no_epg",
	"api_version": {
		"Major": 6,
		"Minor": 1,
		"Patch": 0
	},
	"featuring": {
		"jsonfeatures": {
			"recordings": [
				"List",
				"Schedule",
				"Manage"
			],
			"ambilight": [
				"Hue",
				"HueStreaming",
				"Ambilight"
			],
			"textentry": [
				"context_based",
				"initial_string_available"
			],
			"inputkey": [
				"key",
				"unicode"
			],
			"pointer": [
				"context_based"
			],
			"activities": [
				"browser"
			]
		},
		"systemfeatures": {
			"tvtype": "consumer",
			"content": [
				"dmr"
			],
			"pairing_type": "none",
			"companion_screen": true,
			"os_type": "Linux"
		}
	}
}```

You can use my tool now :slight_smile:

Get a python virtual environment

python3 -m venv venv_philips
. venv_philips/bin/activate

Install tool there

pip install -I git+https://github.com/danielperna84/[email protected]

Run status output command

python -m haphilipsjs -i hostname -a 6 status

Run a specific endpoint

python -m haphilipsjs -i hostname -a 6 get context
python -m haphilipsjs -i hostname -a 6 get channeldb/tv

Also i’ve updated https://github.com/home-assistant/core/pull/46422 with theoretical support for saphi tv.

You can run it as custom component by grabbing the component here: https://minhaskamal.github.io/DownGit/#/home?url=https://github.com/elupus/home-assistant/tree/philips_js_pair/homeassistant/components/philips_js

1 Like

Thanks for your effort so far! :star_struck:
Will give this a try today or tomorrow.

get context
{'level1': 'WatchExtension', 'level2': 'NA', 'level3': 'NA', 'data': 'NA', 'Recording': 'Off'}
get channeldb/tv 
{}
get activities/tv     
{'channel': {}, 'channelList': {}}

The activities browser and current returned with none
I did get these while the input was on HDMI.
To be fair I watch TV with an external box so that might effect some settings.

I tried out the custom component but it doesn’t seem to work for now.
It states an unknown error when trying to connect on all the three API’s.

Here some logs:

Logger: custom_components.philips_js
Source: custom_components/philips_js/config_flow.py:136
Integration: Philips TV (documentation)
First occurred: 11:51:44 (4 occurrences)
Last logged: 11:53:07

System data is empty
Logger: aiohttp.server
Source: custom_components/philips_js/config_flow.py:104
First occurred: 11:51:41 (8 occurrences)
Last logged: 11:53:09

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 118, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 169, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 60, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 106, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 155, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 213, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/config/custom_components/philips_js/config_flow.py", line 152, in async_step_user
    return await self.async_step_pair()
  File "/config/custom_components/philips_js/config_flow.py", line 104, in async_step_pair
    self._pair_state = await self._hub.pairRequest(
  File "/usr/local/lib/python3.8/site-packages/haphilipsjs/__init__.py", line 346, in pairRequest
    raise NoneJsonData(resp.text)
haphilipsjs.NoneJsonData: Non json data received: <html><head><title>Method not allowed</title></head><body>Method not allowed</body></html>

Right I see the problem. I tried to pair while it shouldn’t. I have fixed that issue. Could you try again?

Yes, the tv comes into HA now. For now the only thing that seems to work is to get the state from the tv, on/off. List of applications is empty.
Channels also, but I don’t have this setup, so I expect the channels to be empty.

Logger: haphilipsjs
Source: /usr/local/lib/python3.8/site-packages/haphilipsjs/__init__.py:309
First occurred: 17:02:33 (15 occurrences)
Last logged: 17:03:59

Post failed: {'key': 'VolumeUp'} -> <html><head><title>Method not allowed</title></head><body>Method not allowed</body></html>
Post failed: {'key': 'VolumeDown'} -> <html><head><title>Method not allowed</title></head><body>Method not allowed</body></html>
Post failed: {'key': 'Standby'} -> <html><head><title>Method not allowed</title></head><body>Method not allowed</body></html>

edit:
I never gave the output from the endpoint of activities:

In the tool I get None and in the browser I get forbidden.

Okey. So it’s a start. Strange with volume keys. That i would have expected to work. I wonder if you need to authenticate to get those things.