All,
New binding release! Lots of new features in this.
- Support for SOURCE_NAME
- Support for SOURCE_ID
- Support for CHANNEL
- Support for CHANNEL_NAME
- Three new Frame TV channels
New Support for Old CHANNELS:
On TV’s >2016 the SOURCE_NAME, SOURCE_ID, CHANNEL and CHANNEL_NAME channels weren’t supported, as there was no way to retrieve these values from the websocket interface. You could set CHANNEL, but not read it back.
I have implemented an interface to the Smartthings cloud, in order to be able to access these settings. This allows you to see the current source (TV, HDMI1, HDMI2, etc), and change the input source by sending the appropriate string to the SOUCE_NAME channel. SOURCE_ID is a read only numerical value representing the input source.
NOTE: this is ONLY for TV’s using the websocket interface (ie >2016). Earlier TV’s use UPNP for this functionality.
In order to connect to the Smartthings cloud, there are a few steps to take.
- Set the samsungtv logs to at least DEBUG
- Create a Samsung account (probably already have one when you set up your TV)
- Add Your TV to the Smartthings App
- Go to https://account.smartthings.com/tokens and create a Personal Access Token (PAT). check off all the features you want (I would add them all).
- Go to the Openhab Samsung TV Thing, and update the configuration with your PAT (click on
advanced
). You will fill in Device ID later if necessary.
- Save the Thing, and watch the logs.
The binding will attempt to find the Device ID for your TV. If you have several TV’s, you will have to manually identify the Device ID for the current Thing from the logs. The device ID should look something like 996ff19f-d12b-4c5d-1989-6768a7ad6271
. If you have only one TV, Device ID should get filled in for you.
Once you have the right Device Id, go back to the Thing configuration, and enter the Device ID. Save the update.
You can now link the SOURCE_NAME, SOURCE_ID, CHANNEL and CHANNEL_NAME channels, and should see the values updating. You can change the TV input source by sending "HDMI1"
, or "HDMI2"
to the SOURCE_ID channel, the exact string will depend on your TV, and how many inputs you have.
NOTE: You may not get anything for CHANNEL_NAME, as most TV’s don’t report it. You can only send commands to CHANNEL and SOURCE_NAME, the others are read only.
Legacy TV’s:
I have reworked the entire Legacy TV support system to improve reliability. Let me know if I have broken anything.
Legacy TV NOTE: On TV’s <2016, using the legacy interface, you may see an error similar to this in your logs:
2021-12-08 12:19:50.262 [DEBUG] [port.upnp.internal.UpnpIOServiceImpl] - Error reading SOAP response message. Can't transform message payload: org.jupnp.model.action.ActionException: The argument value is invalid. Invalid number of input or output arguments in XML message, expected 2 but found 1.
This is not an actual error, but is what is returned when a value is polled that does not yet exist, such as the URL for the TV browser, when the browser isn’t running. These messages are not new, and can be ignored.
New Art Channels:
Three new channels, specifically for Frame TV owners (click on advanced
in channels to see them).
- ART_SELECTED
- ART_LABEL
- ARTWORK_JSON
ART_SELECTED:
The first channel, ART_SELECTED is an Image channel, it will show you a thumbnail of the currently selected artwork. This updates in real time if you change the selected artwork. The artwork is shown, irrespective of the TV mode (ie it still shows with the TV on, or in artMode). It will update if you have slideshow enabled, and the artwork changes. Unfortunately Image channels do not support sending commands, so this is really a read only channel.
ART_LABEL:
ART_LABEL is a String channel, that shows the internal label given by the TV for the current artwork. It will also update in real time if the artwork changes. This will be something like MY_F0028
- you will have to determine what this actually represents. On my TV, MY_F0028
is “High Park Cherry Blossom”.
You can send commands to the ART_LABEL channel. If you send another text label (eg MY_F0029
or another valid internal label), the artwork displayed will change to be whatever you send represents. you will have to figure out what your labels are for your TV.
In addition, you can send images to the ART_LABEL channel (because you cant send them to the ART_SELECTED channel). I have tested .jpg
and .png
files, and they both work.The images should be a RawType, or a string representation of a RawType (just like updating an Image item). You could use the FTP Binding or a rule to upload an image to the TV.
This is how you upload a png
image to an item Samsung_TV_Image
linked to the ART_LABEL channel. This is a string representation of a RawType image. The actual image data is base64 encoded and added to the string (in this case iVBORw0KGgoAAA...
is the image data base64 encoded). You can also send a regular RawType variable.
Samsung_TV_Image.sendCommand("data:image/png;base64,iVBORw0KGgoAAA........AAElFTkSuQmCC")
The images you upload should be 3840x2160 pixels in size exactly, to fill the screen. They are uploaded without a mat applied. The uploaded images will not display immediately, they are added to the My Photos
section of My Collection
, and a new Image is uploaded each time you send (ie they don’t get overwritten). You have to view them and/or delete them on the TV. If you have a <2021 Frame TV, you can fill the TV’s internal memory if you are not careful.
ART_JSON:
NOTE: For Developers use only!
The ART_JSON channel is also a String channel, it reports the json received from the websocket art channel on the TV as received (prettied up a bit). You can use this for your own programs/rules. You can also send commands to the TV’s websocket art channel this way.
If you send a plain text command eg "get_artmode_status"
, or "get_auto_rotation_status"
, it is sent wrapped in an artMode websocket json command. The response will be received on the same channel. Sending get_current_artwork
would retrieve a json list of all the artwork currently on your TV.
if you wrap the command with {}
, then the command is sent as json, exactly as you send it (message id is added automatically if you don’t include it), this is so that you can experiment with artMode json commands, that I may not know of.
The current list of commands that I know work are:
get_artmode_status and set
get_auto_rotation_status and set
get_device_info
get_content_list
get_current_artwork
delete_image_list
select_image - selects image to display (display optional)
get_photo_filter_list
set_photo_filter
Some of these command require extra variables, so you have to know what to send (eg delete_image_list
expects you to include an image list, and select_image
expects an image id to be included). Do Not Use This feature unless you have a reason! You have been warned!
Other New features:
The URL channel will now start the browser (but does not fill in the URL - have not figured this out yet). You can exit by sending ON
to the STOP_BROWSER channel, or sending ""
to the APPLICATION channel. However see below:
The KEY_CODE channel now supports mouse move, and actions. Plus new Keys KEY_AMBIENT and KEY_BT_VOICE. key KEY_BT_VOICE simulates pressing (or releasing) the voice button on the remote.
To send mouse actions, you would send to the KEY_CODE channel:
{"x":0, "y":-430},1000,LeftClick
Where “x” and “y” are the coordinates to send the mouse cursor to, followed by a 1 second delay, then a left mouseclick. RightClick
also works.
To send text, enclose the string in ""
, so "http://your_url\r"
would enter the text, followed by a return. You may have to escape the "
using \
depending on how you send the text. this makes it possible to fill in a URL for the browser if you trigger on the URL channel changing, by moving the mouse to the URL entry bar, sending KEY_ENTER
, and entering the text url. I have a rule that does this, but you may need to experiment with the mouse position and timing.
This is my rule (sorry it’s written n Python):
class TVURL(HABApp.Rule):
'''
Send a URL to the TV browser
'''
watch_items = []
change_items = []
command_item = ['TV_Cameras']
items = ['TVRemoteControl',
'TV_Power',
'TV_App']
def __init__(self):
super().__init__()
self.log = logging.getLogger('MyRule.'+self.__class__.__name__)
setup_items(self)
self.url_position = {"x":0, "y":-430}
def command_received(self, event):
self.log.debug('Item %s command received %s' % (event.name, event.value))
if event.name == 'TV_Cameras':
self.set_url(event)
def set_url(self, event):
self.log.info("sending mouse to {}".format(json.dumps(self.url_position)))
#3 second delay, move mouse (relative), click and send url.
delay = 3000
if self.item['TV_Power'].value == 'OFF':
delay = 15000
if self.item['TV_App'].value == 'Internet':
self.oh.send_command(self.item['TVRemoteControl'], 'KEY_ENTER,2000,"{}"'.format(event.value+"\r"))
else:
self.oh.send_command(self.item['TVRemoteControl'], '{},{},1000,KEY_ENTER,2000,"{}"'.format(delay, json.dumps(self.url_position), event.value+"\r"))
TVURL()
The APPLICATION channel has been updated to support artMode commands. Normally this channel allows you to send an application name, or id, to start the application. it also displays the name of the currently running application. Sending ""
to the channel exits the current application.
Now, the channel also displays artMode
if the TV is a Frame TV displaying artwork. It displays an empty string for normal TV mode, Internet
for the web browser, and the slideshow type if the frame TV is displaying a slideshow.
For Example, if a frame TV is showing a random slideshow (in artMode), the display would be:
shuffleslideshow 30 MY-C004
shuffleslideshow
(or slideshow
) is the slideshow type, 30
is the rotation time in minutes, and MY-C004
is the category, one of Favorites
, My Photos
, or My Shelf
- the exact string will vary from TV to TV.
You can also set the slideshow settings by sending a string to the APLLICATIONS channel. The string should be in the same format as that above, with ,
between the fields, but the Category can be left out.
Eg, sending
shuffleslideshow, 1440
Would set a random slideshow, duration 1440 minutes (1 day) using the current category (whatever it is).
NOTE: if you set the current displayed art using the ART_LABEL channel, it will disable any current slideshow you have running.
Text File Configuration:
This is an example of a text thing:
Thing samsungtv:tv:family_room "Samsung The Frame 55" [ hostName="192.168.100.73", port=8002, macAddress="10:2d:42:01:6d:17", refreshInterval=1000, protocol="SecureWebSocket", webSocketToken="16225986", smartThingsApiKey="cae5ac2a-6770-4fa4-a531-4d4e415872be", smartThingsDeviceId="996ff19f-d12b-4c5d-1989-6768a7ad6271" ]
Here are my Items:
String TVRemoteControl "TV Control [%s]" <television> (GF_Family) { channel="samsungtv:tv:family_room:keyCode", autoupdate="false" }
Dimmer TV_Volume "TV Volume [%s]" <soundvolume> (GF_Family) { channel="samsungtv:tv:family_room:volume" }
String TVSource_Name "TV Source [%s]" <television> (GF_Family) { channel="samsungtv:tv:family_room:sourceName" }
Number TV_Channel "Channel [%s]" <television> (GF_Family) { channel="samsungtv:tv:family_room:channel" }
// TV programTitle doesn't work on my TV
// String TV_Title "Program Title [%s]" <television> (GF_Family) { channel="samsungtv:tv:family_room:programTitle" }
String TV_Name "Channel Name [%s]" <television> (GF_Family) { channel="samsungtv:tv:family_room:channelName" }
Number TV_SourceId "Source id [%s]" <television> (GF_Family) { channel="samsungtv:tv:family_room:sourceId" }
/* Frame TV only*/
Switch TV_ArtMode "TV Art Mode [%s]" <television> (GF_Family) { channel="samsungtv:tv:family_room:artMode" }
/* Supported on all TV's */
Switch TV_Power "TV Power [%s]" <television> (GF_Family) { channel="samsungtv:tv:family_room:power" }
Switch TV_Mute "TV Mute [%s]" <soundvolume_mute> (GF_Family) { channel="samsungtv:tv:family_room:mute" }
String TV_Cameras "TV Cameras [%s]" <camera> (GF_Family) { channel="samsungtv:tv:family_room:url", autoupdate="false" }
String TV_App "TV App [%s]" <television> (GF_Family) { channel="samsungtv:tv:family_room:sourceApp" }
Switch TV_StopBrowser "TV Stop Browser [%s]" <television> (GF_Family) { channel="samsungtv:tv:family_room:stopBrowser", autoupdate="false" }
/* New artMode Channels for Frame TV */
String TV_ArtJson "TV ArtJson [%s]" <television> (GF_Family) { channel="samsungtv:tv:family_room:artJson", autoupdate="false" }
String TV_ArtLabel "TV ArtLabel [%s]" <television> (GF_Family) { channel="samsungtv:tv:family_room:artLabel", autoupdate="false" }
Image TV_ArtImage "TV ArtImage" <television> (GF_Family) { channel="samsungtv:tv:family_room:artImage", autoupdate="false" }
And my SiteMap
Switch item=TV_Power mappings=[ON="ON", OFF="OFF"]
Switch item=TV_ArtMode mappings=[ON="ON", OFF="OFF"]
Switch item=TVRemoteControl label="TV POWER" mappings=["-4000,KEY_POWER"="SHUTDOWN", "KEY_POWER"="TOGGLE"]
Slider item=TV_Volume
Setpoint item=TV_Volume minValue=0 maxValue=100 step=1
Switch item=TV_Volume mappings=[INCREASE="increase", DECREASE="decrease"]
Switch item=TV_Mute mappings=[ON="ON", OFF="OFF"]
Text item=TV_Name
Text item=TVSource_Name
Text item=TV_SourceId
Switch item=TVSource_Name mappings=[HDMI1="HDMI 1", HDMI2="HDMI 2", HDMI3="HDMI 3", HDMI4="HDMI 4"]
Switch item=TV_Channel mappings=[3="Ch 3", 6="Ch 6", 23="Ch 23", 123="Ch 123"]
Switch item=TV_Cameras mappings=["http://192.168.100.119/All_Cameras_Motion.html"="All","http://192.168.100.119/Porch_Camera_Motion.html"="Porch","http://192.168.100.119/Hallway_Camera_Motion.html"="Hallway","http://192.168.100.119/Back_Garden_Camera_Motion.html"="Garden","http://192.168.100.119/Side_Garden_Camera_Motion.html"="Side"]
Switch item=TV_App mappings=["Netflix"="Netflix","Apple TV"="Apple TV","Disney+"="Disney+","Tubi"="Tubi","Internet"="Internet",""="Exit"]
Switch item=TV_StopBrowser mappings=[ON="Stop", OFF="Quit"]
Switch item=TV_App label="Slideshow" mappings=["shuffleslideshow,1440"="shuffle 1 day","suffleslideshow,3"="shuffle 3 mins","slideshow,1440"="slideshow 1 day","slideshow,off"="Off"]
Text item=TV_App
Text item=TV_ArtLabel
Switch item=TV_ArtLabel mappings=["MY_F0018"="Millie","MY_F0019"="Cottage","MY_F0028"="High park","MY_F0038"="Vacation","SAM-S0611"="Fosilized Wood"]
Text item=TV_ArtJson
Switch item=TV_ArtJson mappings=["{\"request\":\"get_artmode_status\"}"="Get Art Status","get_content_list"="Get Art List"]
Image item=TV_ArtImage visibility=[TV_ArtImage!=NULL]
Download link org.openhab.binding.samsungtv-3.2.0-SNAPSHOT.jar