Closed tommyjlong closed 5 years ago
@tommyjlong I've added the two sources according to this table https://github.com/Ape/samsungctl/blob/master/README.rst#key-codes. For me this is working with a legacy connection to UE40ES5700. Maybe this was changed with a newer generation. Do you have more information about this interface?
I've created an additional integration based on UPNP/DLNA/SSDP which provides an interface which responds with the actual existing sources. Furthermore it provides the currently viewed TV channel and show title. Are you interested in and help me going further in this direction?
Hi @escoand, I found a more extensive list of codes here: https://github.com/openremote/Documentation/wiki/Samsung-Smart-TV and that is where I found the KEY_TV (this one works in my case). I have an older 2012 ES8000 model. When I use KEY_DTV (and several of the other source related codes), it results in a pop up menu of the TV's sources, but doesn't actually change the source.
I don't know much about this interface. Yes I would be interested in helping. I can at least do some testing.
Fine, a really long list. To test all this in the different TV models we should maybe first add a service samsungtv.send_keycode
to use the interface directly. So many people could get in touch with it and report what is working and what not.
On the other hand we could evaluate if your TV provides also the UPNP interface. I've successfully used https://play.google.com/store/apps/details?id=com.tjjang.upnptool for that. My TV provides 4 UPNP devices with 6 services. You could tinker a bit and look out for urn:samsung.com:service:MainTVAgent2:1
. Hopefully this is the same interface like mine.
The interesting actions are GetSourceList
and GetCurrentMainTVChannel
.
If the UPNP thing is working you could try these files in your config folder with the subfolder custom_components/samsungtv_upnp
.
Additionally you have to add this to your config:
media_player:
- platform: samsungtv_upnp
name: Whatever you want
# the url shown in the UPNP Tool
url: http://192.168.1.34:7676/smp_10_
@escoand I am seeing 4 entries in the UPNP tool for my Samsung (NU8000) TV, but none of them are of the fomat http://
I see the following 4: type:urn:dial-multiscreen-org:device:dialreceiver:1
, type:urn:samsung.com:device:ScreenSharing:1
, type:urn:samsung.com:device:IPControlServer:1
, and type:urn:samsung.com:device:MediaRenderer:1
OK, you see the same UPNP devices, now you have to click onto them and show the info of the services. There is the URL.
At the end this could all be done by ssdp auto discovery but this doesn't work with custom components AFAIK.
Here is some feedback....
My Samsung TV supports UPnP and the MainTVAgent2:1.
(I primarily used Wireshark to capture some of the UPnP dialogue with my machine and the Samsung TV).
When the TV is off, there is no periodic multicasting of UPnP data from the TV. When the TV is turned on, it very quickly sends the UPnP data out and after wards periodically resends it out.
The Custom Component: Two entities show up:
However when the TV is off, neither show up.
When the TV is turned ON, the entities may or may not show up.
Restarting HA helps especially when the TV is ON.
Media Player #1 has typical on/off button, buttons for volume mute/up/down, and source select with entries: TV and HDMI. The TV selection doesn't work, the HDMI does sometimes. It also will goto "IDLE" state after 3-4 minutes even though the TV is still ON (Same problem as existing native HA Samsung Media Player).
Media Player #2 only shows its state (most of the time its IDLE) and Source Selection pull down/current.
The Pull Down List of sources match what is on my TV:
TV,HDMI1/DVI,HDMI2,HDMI-CEC,HDMI-CEC,AV2
Selecting TV and HDMI-CEC (the 1st one) work sometimes, but not that often, and all the other sources don't work at all. The ones that don't work have a debug log entry:
DEBUG (MainThread) [custom_components.samsungtv_upnp.media_player] unable to select source
When TV or HDMI-CEC is selected an exception occurs:
Traceback (most recent call last):
File "/opt/homeassistant/homeassistant_venv_3.6/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 220, in async_update_ha_state
await self.async_device_update()
File "/opt/homeassistant/homeassistant_venv_3.6/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 375, in async_device_update
await self.async_update()
File "/home/tommy/.homeassistant/custom_components/samsungtv_upnp/media_player.py", line 198, in async_update
await self._get_media_info()
File "/home/tommy/.homeassistant/custom_components/samsungtv_upnp/media_player.py", line 333, in _get_media_info
self._media_title = result['ProgramTitle']
KeyError: 'ProgramTitle'
and is sometimes but not always accompanied by the debug log entry:
DEBUG (MainThread) [custom_components.samsungtv_upnp.media_player] unable to get media title
and continues to repeat every few seconds.
now you have to click onto them and show the info of the services. There is the URL.
Even after I click on the i
, I don't see the http://
URL. Can you share a screenshot of what you we are looking for?
[Update] I managed to get a UPnP Tool "Device Spy" up and running.
GetSourceList
shows the following inputs: TV (ID=0), HDMI1/DVI (ID=67), HDMI2 (ID=68), HDMI-CEC (ID=0), HDMI-CEC (ID=1), AV1 (ID=55), AV2 (ID=56), COMPONENT (ID=61), HDMI3 (ID=69)
The sources COMPONENT, AV1, HDMI3 are also indicated as having nothing connected.
Note that these same 3 sources do not appear in the HA Media Player#2.
However it turns out there is actually a BD player connected to HDMI3 but the player was asleep. As we'll see below HDMI3 is a valid source.
Using SetMainTVSource
, the ID has to be set properly (UiID can always be 0). The default ID=0 works only for a couple of these.
The line result = await action.async_call(Source=source, ID=0, UiID=0)
looks like would need to include the ID.
Trying to set source to AV1 and COMPONENT (along with their respective IDs) fails with return indicating nothing connected.
Setting source to HDMI3 (and its ID) is successful. It woke up the BD player that was connected to it.
When invoking GetSourceList again, it now shows HDMI3 as having something connected to it.
OK, thanks for the feedback. It reflects exactly my current state - proof of concept, not more. For me the media info was of interest and is working when watching TV. It's my very first own integration so don't be too exited. I'll create a pull request for this new integration. In this issue we should focus on the current implementation.
Ok, my URL was completely different. This worked for me:
media_player:
- platform: samsungtv_upnp
name: SammyTV
url: http://192.168.2.252:9197/dmr
For those who are struggling to find the URL, I used dlnap.
I've opened the PR https://github.com/home-assistant/home-assistant/pull/25044. You're welcome to add your comments or code...
Back to this issue. I've to test if the KEY_TV is working on my device as well but currently it is in use. ;-)
Added the custom components to my Home-Assistant setup for my Samsung Frame (2018) and this to my configuration:
But media player stays in idle
@Imperial-Guard please use the PR #25044 for the new component.
Used the new component but media player stays still in idle
@Imperial-Guard if I understand you right you're using samsungtv_upnp
but this issue is about samsungtv
. So please post your questions regarding samsungtv_upnp
to the corresponding PR.
Ok, my URL was completely different. This worked for me:
media_player: - platform: samsungtv_upnp name: SammyTV url: http://192.168.2.252:9197/dmr
For those who are struggling to find the URL, I used dlnap.
I used also dlnap and only recieved the ip address, some thoughts how to get the response of the port?
@Imperial-Guard PLEASE STOP USING THIS ISSUE FOR PROBLEMS WITH THE NEW INTEGRATION.
@tommyjlong I've added the two sources according to this table https://github.com/Ape/samsungctl/blob/master/README.rst#key-codes. For me this is working with a legacy connection to UE40ES5700. Maybe this was changed with a newer generation. Do you have more information about this interface?
I've created an additional integration based on UPNP/DLNA/SSDP which provides an interface which responds with the actual existing sources. Furthermore it provides the currently viewed TV channel and show title. Are you interested in and help me going further in this direction?
how to get different HDMI ports like HDMI 1, HDMI 2........ guide thanks
@earth08 this component is emulating the actual remote. If there are no buttons for HDMI1/2 it's likely to not be able to add it.
@tommyjlong The KEY_TV is working on my TV as well. So we can switch to it. @earth08 I tried the KEY_HDMI1/2/3/4 keys mentioned in one link above, but they do not work for me.
Great to hear!!
I have a UA-55KU7970 TV and none of the KEY_TV
or KEY_DTV
could switch HDMI to TV Source.
I found that it's possible to switch the source to TV by sending KEY_CHUP
or KEY_CHDOWN
keys instead.
Home Assistant release with the issue:
0.95.4
Last working Home Assistant release (if known):
Operating environment (Hass.io/Docker/Windows/etc.):
Hass in python venv Component/platform:
Samsungtv
Description of problem: Source Selection "TV" doesn't work.
I currently use command line platform and use samsungctl to select the source of my Samsung TV.
To select my Over The Air source I use: KEY_SOURCE KEY_TV. To select my HDMI input, I use: KEY_SOURCE KEY_HDMI. With the new source selection feature introduced in 0.95 selecting source "HDMI" works!! The new feature simply changes the service parameter "source" "HDMI" to "KEY_HDMI".
However it changes "TV" to "KEY_DTV". "KEY_DTV" does not work in my case.
Suggest changing the mapping of "TV" to "KEY_TV" and add a new mapping of "DTV" to KEY_DTV".
(Ideally, this feature would take a string from the service "source" and simply add "KEY_" to it.)
Problem-relevant
configuration.yaml
entries and (fill out even if it seems unimportant):Traceback (if applicable):
Additional information: