Custom Widget: Samsung TV Remote

Hello everybody,
I’ve wanted to explore HABPanel and his custom widget feature, this is my first attempt so be kind if something does not work…I don’t know even if I can help troubleshooting :slight_smile:

So I tried with a Remote for Samsung TV (tested on my tablet: Samsung Tab 4 10’’)

Many credits go to Andy ( See this post ) . I took his template for the basic structure and swipe functionalty.

The widget settings are quite self explanatory the only requirement is:

  • TV Keycode Item-> KeyCode Item of the Samsung TV binding.

It looks better with a size of 3x2 but it should scale up to any size, it looks decent on my smartphone too.


(screenshot taken with dark material theme but should play well on every “dark” theme).

Here the JSON: Samsung TV Remote.widget.json (12.6 KB)

After I came up with this widget I realized that is not comfortable to have a big widget always occupying my dashboard, so credits to Yannick ( See this post ) I tried to make a nested custom widget to launch the remote on a modal window.

immagine
(screenshot of the launcher)

Here the JSON of the remote “launcher” Samsung TV Remote Launcher.widget.json (2.0 KB)

remote
(remote icon I use for the launcher)

If you import both widgets, you only have to put and configure the launcher on your Dashboard.
The launcher config are self explanatory too (I think) but thees ones are mandatory:

  • TV Remote Widget Name -> It’s the name you gave to the remote widget when importing it (change it if you changed the default name while importing the remote widget)

  • TV KeyCode Item -> KeyCode item of the Samsung TV binding

  • TV Remote Icon -> Icon to be displayed in the button

Hope it can be helpful to someone…otherwise…well it’s helpful to me! :smiley:

5 Likes

Hi Alessio

I am new to openhab. The remote looks really cool. However, I am not clear TV KeyCode Item value I need to provide. is it the binding id samsungtv? I tried it but it’s not working.

Thanks

Hi,
It’s meant to be working with the Samsung tv binding.
If you have the binding installed create an item linked to the keyCode channel of the binding.
Then provide that item to the widget and it should work.

Hi Alessio.

It’s been quite a while since the last post on this topic…

Based on a widget by @Bernd_Ritter I’ve created an alternative Samsung TV Remote widget which works with the “Samsung TV Binding (Beta)” from the Community Marketplace specialized for the Samsung “The Frame”.

It works well on the Samsung Z-Fold mobile phone and on tablets.

Maybe someone finds this helpful!?

Here’s the widget code.

SamsungTheFrameRemoteWidget.txt (51.7 KB)

The image-files need to have the same name as the commands for the channels.

Here’s the rule to send the channel number based on the channel button on the right:

var Timer TVWohnzimmerTimer			= null

//Power ON/OFF
rule TV_Wohnzimmer_Power
when 
	Item TV_Wohnzimmer_Power changed 
then 
	if (TVWohnzimmerTimer !== null)
		{
			TVWohnzimmerTimer.cancel
			TVWohnzimmerTimer = null
		}
	if (TV_Wohnzimmer_Power.state == OFF)
	{		
		TVWohnzimmerTimer = createTimer(now.plusSeconds(3))
			[ | if (TV_Wohnzimmer_ArtMode.state == ON)
				{
					TV_Wohnzimmer_ArtMode.sendCommand(OFF)
				}
			]
	}
	else 
	{			
		TVWohnzimmerTimer = createTimer(now.plusSeconds(5))		
			[ | TV_Wohnzimmer_KeyCode.sendCommand("")
				TV_Wohnzimmer_KeyCode.sendCommand("EXIT")
				TVWohnzimmerTimer = createTimer(now.plusSeconds(2))		
				[ | TV_Wohnzimmer_KeyCode.sendCommand("")
					TV_Wohnzimmer_KeyCode.sendCommand("EXIT")
					TV_Wohnzimmer_KeyCode.sendCommand("")			
				]				
			]
	}
end 


//Mute-Unmute TV
rule TV_Wohnzimmer_Mute
when 
	Item TVC_WohnzimmerMute changed 
then 
	TV_Wohnzimmer_KeyCode.sendCommand("")
	TV_Wohnzimmer_KeyCode.sendCommand("MUTE")
	TV_Wohnzimmer_KeyCode.sendCommand("")
end


//Switch to Channel:
rule TVC_WohnzimmerTVChannel
when 
	Item TVC_WohnzimmerTVChannel received update
then 
	switch (TVC_WohnzimmerTVChannel.state)
	{
		case "ARD":				{ TV_Wohnzimmer_KeyCode.sendCommand("1") }
		case "ZDF":				{ TV_Wohnzimmer_KeyCode.sendCommand("2") }
		case "WDR":				{ TV_Wohnzimmer_KeyCode.sendCommand("3") }
		case "RTL":				{ TV_Wohnzimmer_KeyCode.sendCommand("5") }
		case "RTL2": 			{ TV_Wohnzimmer_KeyCode.sendCommand("6") }
		case "PRO7": 			{ TV_Wohnzimmer_KeyCode.sendCommand("7") }
		case "SAT1": 			{ TV_Wohnzimmer_KeyCode.sendCommand("8") }
		case "VOX":  			{ TV_Wohnzimmer_KeyCode.sendCommand("9") }
		case "Kabel1": 			{ TV_Wohnzimmer_KeyCode.sendCommand("1") TV_Wohnzimmer_KeyCode.sendCommand("0") }
		case "SuperRTL":		{ TV_Wohnzimmer_KeyCode.sendCommand("1") TV_Wohnzimmer_KeyCode.sendCommand("1") }
		case "DMAX":			{ TV_Wohnzimmer_KeyCode.sendCommand("1") TV_Wohnzimmer_KeyCode.sendCommand("2") }
		case "Sport1":			{ TV_Wohnzimmer_KeyCode.sendCommand("1") TV_Wohnzimmer_KeyCode.sendCommand("3") }
		case "ArteHD":			{ TV_Wohnzimmer_KeyCode.sendCommand("1") TV_Wohnzimmer_KeyCode.sendCommand("4") }
		case "Tele5":			{ TV_Wohnzimmer_KeyCode.sendCommand("1") TV_Wohnzimmer_KeyCode.sendCommand("5") }
		case "Kabel1Doku":		{ TV_Wohnzimmer_KeyCode.sendCommand("1") TV_Wohnzimmer_KeyCode.sendCommand("6") }
		case "ZDFneo":			{ TV_Wohnzimmer_KeyCode.sendCommand("1") TV_Wohnzimmer_KeyCode.sendCommand("7") }
		case "3satHD":			{ TV_Wohnzimmer_KeyCode.sendCommand("1") TV_Wohnzimmer_KeyCode.sendCommand("8") }
		case "AlphaHD":			{ TV_Wohnzimmer_KeyCode.sendCommand("1") TV_Wohnzimmer_KeyCode.sendCommand("9") }
		case "ZDFinfoHD":		{ TV_Wohnzimmer_KeyCode.sendCommand("2") TV_Wohnzimmer_KeyCode.sendCommand("0") }
		case "N24Doku":			{ TV_Wohnzimmer_KeyCode.sendCommand("2") TV_Wohnzimmer_KeyCode.sendCommand("1") }
		case "Tagesschau24HD":	{ TV_Wohnzimmer_KeyCode.sendCommand("2") TV_Wohnzimmer_KeyCode.sendCommand("2") }
		case "Phoenix":			{ TV_Wohnzimmer_KeyCode.sendCommand("2") TV_Wohnzimmer_KeyCode.sendCommand("3") }
		case "Nitro":			{ TV_Wohnzimmer_KeyCode.sendCommand("2") TV_Wohnzimmer_KeyCode.sendCommand("4") }
		case "ToggoPlus":		{ TV_Wohnzimmer_KeyCode.sendCommand("2") TV_Wohnzimmer_KeyCode.sendCommand("5") }
		case "KiKAHD":			{ TV_Wohnzimmer_KeyCode.sendCommand("2") TV_Wohnzimmer_KeyCode.sendCommand("6") }
		case "Nick":			{ TV_Wohnzimmer_KeyCode.sendCommand("2") TV_Wohnzimmer_KeyCode.sendCommand("7") }
		case "RTLup":			{ TV_Wohnzimmer_KeyCode.sendCommand("2") TV_Wohnzimmer_KeyCode.sendCommand("8") }
		case "SIXX":			{ TV_Wohnzimmer_KeyCode.sendCommand("2") TV_Wohnzimmer_KeyCode.sendCommand("9") }
		case "7MaxxHD":			{ TV_Wohnzimmer_KeyCode.sendCommand("3") TV_Wohnzimmer_KeyCode.sendCommand("0") }
		case "Sat1Gold":		{ TV_Wohnzimmer_KeyCode.sendCommand("3") TV_Wohnzimmer_KeyCode.sendCommand("1") }
		case "VOXup":			{ TV_Wohnzimmer_KeyCode.sendCommand("3") TV_Wohnzimmer_KeyCode.sendCommand("2") }
		case "BRHD":			{ TV_Wohnzimmer_KeyCode.sendCommand("3") TV_Wohnzimmer_KeyCode.sendCommand("3") }
		case "HRHD":			{ TV_Wohnzimmer_KeyCode.sendCommand("3") TV_Wohnzimmer_KeyCode.sendCommand("4") }
		case "MDRThueringen":	{ TV_Wohnzimmer_KeyCode.sendCommand("3") TV_Wohnzimmer_KeyCode.sendCommand("5") }
		case "NDRHD":			{ TV_Wohnzimmer_KeyCode.sendCommand("3") TV_Wohnzimmer_KeyCode.sendCommand("6") }
		case "RbbHD":			{ TV_Wohnzimmer_KeyCode.sendCommand("3") TV_Wohnzimmer_KeyCode.sendCommand("7") }
		case "SRHD":			{ TV_Wohnzimmer_KeyCode.sendCommand("3") TV_Wohnzimmer_KeyCode.sendCommand("8") }
		//case "":				{ TV_Wohnzimmer_KeyCode.sendCommand("3") TV_Wohnzimmer_KeyCode.sendCommand("9") }
		case "AnixeHD":			{ TV_Wohnzimmer_KeyCode.sendCommand("4") TV_Wohnzimmer_KeyCode.sendCommand("0") }
		case "OneHD":			{ TV_Wohnzimmer_KeyCode.sendCommand("4") TV_Wohnzimmer_KeyCode.sendCommand("1") }
		case "ServusTVHD":		{ TV_Wohnzimmer_KeyCode.sendCommand("4") TV_Wohnzimmer_KeyCode.sendCommand("2") }
		case "WeltDerWunder":	{ TV_Wohnzimmer_KeyCode.sendCommand("4") TV_Wohnzimmer_KeyCode.sendCommand("3") }
		case "Aljazeera":		{ TV_Wohnzimmer_KeyCode.sendCommand("4") TV_Wohnzimmer_KeyCode.sendCommand("4") }
		case "BBCWorldNews":	{ TV_Wohnzimmer_KeyCode.sendCommand("4") TV_Wohnzimmer_KeyCode.sendCommand("5") }
		case "Bloomberg":		{ TV_Wohnzimmer_KeyCode.sendCommand("4") TV_Wohnzimmer_KeyCode.sendCommand("6") }
		case "CNBCEurope":		{ TV_Wohnzimmer_KeyCode.sendCommand("4") TV_Wohnzimmer_KeyCode.sendCommand("7") }
		case "CNews":			{ TV_Wohnzimmer_KeyCode.sendCommand("4") TV_Wohnzimmer_KeyCode.sendCommand("8") }
		case "CNN":				{ TV_Wohnzimmer_KeyCode.sendCommand("4") TV_Wohnzimmer_KeyCode.sendCommand("9") }
		case "Euronews":		{ TV_Wohnzimmer_KeyCode.sendCommand("5") TV_Wohnzimmer_KeyCode.sendCommand("0") }
		case "NHKWorld":		{ TV_Wohnzimmer_KeyCode.sendCommand("5") TV_Wohnzimmer_KeyCode.sendCommand("1") }
		case "SkyNews":			{ TV_Wohnzimmer_KeyCode.sendCommand("5") TV_Wohnzimmer_KeyCode.sendCommand("2") }

	}
	TV_Wohnzimmer_KeyCode.sendCommand("ENTER")
end 

And the items file:

Switch			TVC_WohnzimmerMute				"Mute"
String 			TVC_WohnzimmerTVChannel			"Kanal"

Dimmer			TV_Wohnzimmer_Volume			"Volume"			<soundvolume>		(gTV_Wohnzimmer)	{channel="samsungtv:tv:Wohnzimmer:volume"}
Switch			TV_Wohnzimmer_Mute				"Mute"				<soundvolume_mute>	(gTV_Wohnzimmer)	{channel="samsungtv:tv:Wohnzimmer:mute"}
Dimmer			TV_Wohnzimmer_Brightness		"Brightness"							(gTV_Wohnzimmer)	{channel="samsungtv:tv:Wohnzimmer:brightness"}
Dimmer			TV_Wohnzimmer_Contrast			"Contrast"								(gTV_Wohnzimmer)	{channel="samsungtv:tv:Wohnzimmer:contrast"}
Dimmer			TV_Wohnzimmer_Sharpness			"Sharpness"								(gTV_Wohnzimmer)	{channel="samsungtv:tv:Wohnzimmer:sharpness"}
Number			TV_Wohnzimmer_ColorTemperature	"ColorTemperature"						(gTV_Wohnzimmer)	{channel="samsungtv:tv:Wohnzimmer:colorTemperature"}
String			TV_Wohnzimmer_SourceName		"Source Name"							(gTV_Wohnzimmer)	{channel="samsungtv:tv:Wohnzimmer:sourceName"}
Number			TV_Wohnzimmer_SourceId			"Source ID"								(gTV_Wohnzimmer)	{channel="samsungtv:tv:Wohnzimmer:sourceId"}
Number			TV_Wohnzimmer_Channel			"Channel"								(gTV_Wohnzimmer)	{channel="samsungtv:tv:Wohnzimmer:channel"}
String			TV_Wohnzimmer_ProgramTitle		"Program Title"							(gTV_Wohnzimmer)	{channel="samsungtv:tv:Wohnzimmer:programTitle"}
String			TV_Wohnzimmer_ChannelName		"Channel Name"							(gTV_Wohnzimmer)	{channel="samsungtv:tv:Wohnzimmer:channelName"}
String			TV_Wohnzimmer_Url				"Url"									(gTV_Wohnzimmer)	{channel="samsungtv:tv:Wohnzimmer:url"}
Switch			TV_Wohnzimmer_StopBrowser		"Stop Browser"							(gTV_Wohnzimmer)	{channel="samsungtv:tv:Wohnzimmer:stopBrowser"}
Switch			TV_Wohnzimmer_Power				"Power"									(gTV_Wohnzimmer)	{channel="samsungtv:tv:Wohnzimmer:power"}
Switch			TV_Wohnzimmer_ArtMode			"Art Mode"								(gTV_Wohnzimmer)	{channel="samsungtv:tv:Wohnzimmer:artMode"}
String			TV_Wohnzimmer_SourceApp			"Source App"							(gTV_Wohnzimmer)	{channel="samsungtv:tv:Wohnzimmer:sourceApp"}
String			TV_Wohnzimmer_KeyCode			"Key Code"								(gTV_Wohnzimmer)	{channel="samsungtv:tv:Wohnzimmer:keyCode"}


Dimmer			TV_Schlafzimmer_Volume			"Volume"			<soundvolume>		(gTV_Schlafzimmer)	{channel="samsungtv:tv:Schlafzimmer:volume"}
Switch			TV_Schlafzimmer_Mute			"Mute"				<soundvolume_mute>	(gTV_Schlafzimmer)	{channel="samsungtv:tv:Schlafzimmer:mute"}
Dimmer			TV_Schlafzimmer_Brightness		"Brightness"							(gTV_Schlafzimmer)	{channel="samsungtv:tv:Schlafzimmer:brightness"}
Dimmer			TV_Schlafzimmer_Contrast		"Contrast"								(gTV_Schlafzimmer)	{channel="samsungtv:tv:Schlafzimmer:contrast"}
Dimmer			TV_Schlafzimmer_Sharpness		"Sharpness"								(gTV_Schlafzimmer)	{channel="samsungtv:tv:Schlafzimmer:sharpness"}
//Number	TV_Schlafzimmer_ColorTemperature	"ColorTemperature"						(gTV_Schlafzimmer)	{channel="samsungtv:tv:Schlafzimmer:colorTemperature"}
String			TV_Schlafzimmer_SourceName		"Source Name"							(gTV_Schlafzimmer)	{channel="samsungtv:tv:Schlafzimmer:sourceName"}
//Number	TV_Schlafzimmer_SourceId			"Source ID"								(gTV_Schlafzimmer)	{channel="samsungtv:tv:Schlafzimmer:sourceId"}
String			TV_Schlafzimmer_Channel			"Channel"								(gTV_Schlafzimmer)	{channel="samsungtv:tv:Schlafzimmer:channel"}
String			TV_Schlafzimmer_ProgramTitle	"Program Title"							(gTV_Schlafzimmer)	{channel="samsungtv:tv:Schlafzimmer:programTitle"}
//String	TV_Schlafzimmer_ChannelName			"Channel Name"							(gTV_Schlafzimmer)	{channel="samsungtv:tv:Schlafzimmer:channelName"}
String			TV_Schlafzimmer_Url				"Url"									(gTV_Schlafzimmer)	{channel="samsungtv:tv:Schlafzimmer:url"}
Switch			TV_Schlafzimmer_StopBrowser		"Stop Browser"							(gTV_Schlafzimmer)	{channel="samsungtv:tv:Schlafzimmer:stopBrowser"}
Switch			TV_Schlafzimmer_Power			"Power"									(gTV_Schlafzimmer)	{channel="samsungtv:tv:Schlafzimmer:power"}
//Switch	TV_Schlafzimmer_ArtMode				"Art Mode"								(gTV_Schlafzimmer)	{channel="samsungtv:tv:Schlafzimmer:artMode"}
String			TV_Schlafzimmer_SourceApp		"Source App"							(gTV_Schlafzimmer)	{channel="samsungtv:tv:Schlafzimmer:sourceApp"}
String			TV_Schlafzimmer_KeyCode			"Key Code"								(gTV_Schlafzimmer)	{channel="samsungtv:tv:Schlafzimmer:keyCode"}



/* KeyCodes:
Can be found here (somewhat): https://github.com/openhab/openhab1-addons/wiki/Samsung-TV-Binding

GUIDE 
RETURN
EXIT
VOLUP
VOLDOWN
MUTE
POWER
CHUP
CHDOWN

CH_LIST

REC
PLAY
PAUSE
REWIND

LEFT
RIGHT
ENTER

RED
YELLOW

SOURCE

SUB_TITLE

TOOLS


Soure-Apps:
Prime Video
Netflix
artMode
Apple TV
Disney+
Tubi


*/


Enjoy!

Kind regards,
Ralph…

1 Like