Philips Smart TVs also with SAPHI OS

Can you set a direct volume on the slider?

@Kev1 do you think you can give it a try? You seem to have channels perhaps?

@Luitertje can you check if the endpoint “sources” or “sources/current” on either 1 or 6 happen to give any data.

Yes I would love to give It a go, I’m fairly new to Home Assistant, so I would need a step by step guide to Install?

You can grab this zip: DownGit

Make sure the extracted files ends up in folder called custom_components inside your config directory.

They all return None in the tool and give Forbidden in the browser.

Nope, unfortunately I can’t set the volume with the slider.

Do you get a current volume in home assistant?

And what does: http://hostname:1925/6/volume/current report?

Sorry I meant: http://hostname:1925/6/audio/volume

on audio/volume

{
	"muted": false,
	"current": 16,
	"min": 0,
	"max": 60
}

I’m still trying to get mine working, but i’ve noticed current volume does not change if you are using a soundbar but on internal tv speakers it does.

Hmm… also a soundbar here. But still no succes if I play the sound through the tv.
Errors are still the same.

Afternoon gents.

I have had some success on this.

On/Off works(standby)
Vol +/- and mute works
Current Chanel Is reported
Play/Pause works.

Below are some screen shots…

Nice. Did you do something extra?

@Luitertje, @Kev1 what API version did you guys choose? You seem to have same version tv software. Maybe you are running different API versions?

I tried API 1 and 6. Those showed the TV in HA.
However, I lost connection with the TV. I upgraded to the latest beta this morning.
At first I thought it was because of the beta. But the tool also doesn’t want to connect to it, nor do I get a respons in the broswer :frowning:

Logger: custom_components.philips_js
Source: custom_components/philips_js/config_flow.py:136
Integration: Philips TV (documentation)
First occurred: 12:01:36 (7 occurrences)
Last logged: 12:14:16

[Errno 111] Connect call failed ('192.168.178.29', 1925)
(venv_philips1) root@CT101:~# python -m haphilipsjs -i 192.168.178.29 -a 1 status
System: None
Source: None
Channel: None: None
Context: None
Application: None
Power State: None
Screen State: None
Traceback (most recent call last):
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_exceptions.py", line 326, in map_exceptions
    yield
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_client.py", line 1502, in _send_single_request
    (status_code, headers, stream, ext,) = await transport.arequest(
  File "/root/venv_philips1/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 218, in arequest
    response = await connection.arequest(
  File "/root/venv_philips1/lib/python3.8/site-packages/httpcore/_async/connection.py", line 93, in arequest
    self.socket = await self._open_socket(timeout)
  File "/root/venv_philips1/lib/python3.8/site-packages/httpcore/_async/connection.py", line 119, in _open_socket
    return await self.backend.open_tcp_stream(
  File "/root/venv_philips1/lib/python3.8/site-packages/httpcore/_backends/auto.py", line 44, in open_tcp_stream
    return await self.backend.open_tcp_stream(
  File "/root/venv_philips1/lib/python3.8/site-packages/httpcore/_backends/asyncio.py", line 270, in open_tcp_stream
    return SocketStream(
  File "/usr/local/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/root/venv_philips1/lib/python3.8/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions
    raise to_exc(exc) from None
httpcore.ConnectError: [Errno 111] Connect call failed ('192.168.178.29', 1925)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/root/venv_philips1/lib/python3.8/site-packages/haphilipsjs/__init__.py", line 282, in _getReq
    resp = await self.session.get(self._url(path), timeout=TIMEOUT)
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_client.py", line 1548, in get
    return await self.request(
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_client.py", line 1371, in request
    response = await self.send(
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_client.py", line 1406, in send
    response = await self._send_handling_auth(
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_client.py", line 1444, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_client.py", line 1476, in _send_handling_redirects
    response = await self._send_single_request(request, timeout)
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_client.py", line 1502, in _send_single_request
    (status_code, headers, stream, ext,) = await transport.arequest(
  File "/usr/local/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_exceptions.py", line 343, in map_exceptions
    raise mapped_exc(message, **kwargs) from exc  # type: ignore
httpx.ConnectError: [Errno 111] Connect call failed ('192.168.178.29', 1925)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/root/venv_philips1/lib/python3.8/site-packages/haphilipsjs/__main__.py", line 223, in <module>
    asyncio.run(main())
  File "/usr/local/lib/python3.8/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/root/venv_philips1/lib/python3.8/site-packages/haphilipsjs/__main__.py", line 181, in main
    print('Ambilight mode: {}'.format(await tv.getAmbilightMode()))
  File "/root/venv_philips1/lib/python3.8/site-packages/haphilipsjs/__init__.py", line 736, in getAmbilightMode
    data = await self._getReq('ambilight/mode')
  File "/root/venv_philips1/lib/python3.8/site-packages/haphilipsjs/__init__.py", line 287, in _getReq
    raise ConnectionFailure(str(err)) from err
haphilipsjs.ConnectionFailure: [Errno 111] Connect call failed ('192.168.178.29', 1925)
/root/venv_philips1/lib/python3.8/site-packages/httpx/_client.py:1781: UserWarning: Unclosed <httpx.AsyncClient object at 0x7fcb21705910>. See https://www.python-httpx.org/async/#opening-and-closing-clients for details.
(venv_philips1) root@CT101:~# python -m haphilipsjs -i 192.168.178.29 -a 6 status
System: None
Source: None
Channel: None: None
Context: None
Application: None
Power State: None
Screen State: None
Traceback (most recent call last):
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_exceptions.py", line 326, in map_exceptions
    yield
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_client.py", line 1502, in _send_single_request
    (status_code, headers, stream, ext,) = await transport.arequest(
  File "/root/venv_philips1/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 218, in arequest
    response = await connection.arequest(
  File "/root/venv_philips1/lib/python3.8/site-packages/httpcore/_async/connection.py", line 93, in arequest
    self.socket = await self._open_socket(timeout)
  File "/root/venv_philips1/lib/python3.8/site-packages/httpcore/_async/connection.py", line 119, in _open_socket
    return await self.backend.open_tcp_stream(
  File "/root/venv_philips1/lib/python3.8/site-packages/httpcore/_backends/auto.py", line 44, in open_tcp_stream
    return await self.backend.open_tcp_stream(
  File "/root/venv_philips1/lib/python3.8/site-packages/httpcore/_backends/asyncio.py", line 270, in open_tcp_stream
    return SocketStream(
  File "/usr/local/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/root/venv_philips1/lib/python3.8/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions
    raise to_exc(exc) from None
httpcore.ConnectError: [Errno 111] Connect call failed ('192.168.178.29', 1925)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/root/venv_philips1/lib/python3.8/site-packages/haphilipsjs/__init__.py", line 282, in _getReq
    resp = await self.session.get(self._url(path), timeout=TIMEOUT)
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_client.py", line 1548, in get
    return await self.request(
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_client.py", line 1371, in request
    response = await self.send(
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_client.py", line 1406, in send
    response = await self._send_handling_auth(
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_client.py", line 1444, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_client.py", line 1476, in _send_handling_redirects
    response = await self._send_single_request(request, timeout)
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_client.py", line 1502, in _send_single_request
    (status_code, headers, stream, ext,) = await transport.arequest(
  File "/usr/local/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/root/venv_philips1/lib/python3.8/site-packages/httpx/_exceptions.py", line 343, in map_exceptions
    raise mapped_exc(message, **kwargs) from exc  # type: ignore
httpx.ConnectError: [Errno 111] Connect call failed ('192.168.178.29', 1925)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/root/venv_philips1/lib/python3.8/site-packages/haphilipsjs/__main__.py", line 223, in <module>
    asyncio.run(main())
  File "/usr/local/lib/python3.8/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/root/venv_philips1/lib/python3.8/site-packages/haphilipsjs/__main__.py", line 181, in main
    print('Ambilight mode: {}'.format(await tv.getAmbilightMode()))
  File "/root/venv_philips1/lib/python3.8/site-packages/haphilipsjs/__init__.py", line 736, in getAmbilightMode
    data = await self._getReq('ambilight/mode')
  File "/root/venv_philips1/lib/python3.8/site-packages/haphilipsjs/__init__.py", line 287, in _getReq
    raise ConnectionFailure(str(err)) from err
haphilipsjs.ConnectionFailure: [Errno 111] Connect call failed ('192.168.178.29', 1925)
/root/venv_philips1/lib/python3.8/site-packages/httpx/_client.py:1781: UserWarning: Unclosed <httpx.AsyncClient object at 0x7fadaee94910>. See https://www.python-httpx.org/async/#opening-and-closing-clients for details.

Hmm… I got connection once more. Pulled the power plug.

Edit: Sound now also works and turning the tv off (API 6)

Could any of you check if these endpoints exist (on v6 api):

ambilight/supportedstyles
ambilight/currentconfiguration

	"supportedStyles": [
		{
			"styleName": "OFF"
		},
		{
			"styleName": "FOLLOW_VIDEO"
		},
		{
			"styleName": "FOLLOW_AUDIO",
			"algorithms": [
				"ENERGY_ADAPTIVE_BRIGHTNESS",
				"ENERGY_ADAPTIVE_COLORS",
				"VU_METER",
				"SPECTRUM_ANALYZER",
				"KNIGHT_RIDER_CLOCKWISE",
				"KNIGHT_RIDER_ALTERNATING",
				"RANDOM_PIXEL_FLASH",
				"STROBE",
				"PARTY"
			],
			"maxTuning": 2
		},
		{
			"styleName": "FOLLOW_COLOR",
			"algorithms": [
				"MANUAL_HUE",
				"AUTOMATIC_HUE"
			],
			"maxSpeed": 255
		}
	]
}```
	"styleName": "FOLLOW_VIDEO",
	"isExpert": false,
	"menuSetting": "VIVID",
	"stringValue": "Vivid"
}

Thanks. They seem to match the android version. Christ the android version is buggy. I have manual control of ambilight now in place. But i don’t control the styles this way. Would be interesting to see if you could test the pull here: https://github.com/home-assistant/core/pull/44867 and see if it works on saphi tv’s