Anyone a better approach to Virtual Remote Control for Roku, Plex, etc

Hello all,

I have been struggling to get a semblance of a remote control (the buttons) with the UI. As you can’t mix HTML/Images with sitemaps (or am I missing something?) I came up with the following, but it is not ideal due to the font alignment. Does anyone have a better idea?

Sitemap:

		    	Frame label='Controller Roku'
			{
			Switch item=rokunavigate  mappings=['1'='__↰__','2'='___⬆___','3'='_HOME_']
			Switch item=rokunavigate  mappings=['4'='__⬅__','5'='__OK__','6'='___➨___']
			Switch item=rokunavigate  mappings=['7'='_PORN_','8'='___⬇___','9'='_PLEX__']	
			Switch item=rokunavigate  mappings=['10'='___❮❮__','11'='_|| ❯_','12'='___❯❯___']

			}

Item File:

Number rokunavigate   
 Switch 	Roku_home		"Home"			<video>					(Roku_navigation, Dev)		{http=">[*:POST:http://192.168.0.38:8060/keypress/home]", autoupdate="False"}
    Switch 	Roku_plex		"Plex"			<plex>					(Roku_navigation, Dev) 		{http=">[*:POST:http://192.168.0.38:8060/launch/dev?contentID=1]",autoupdate="False"}
    Switch 	Roku_back		"back"			<control_return>		(Roku_navigation, Dev)		{http=">[*:POST:http://192.168.0.38:8060/keypress/back]",autoupdate="False"}
    Switch 	Roku_up 		"Up"			<arrow_up>				(Roku_navigation, Dev)		{http=">[*:POST:http://192.168.0.38:8060/keypress/up]", autoupdate="False"}		
    Switch 	Roku_down 		"down"			<arrow_down>			(Roku_navigation, Dev)		{http=">[*:POST:http://192.168.0.38:8060/keypress/down]", autoupdate="False"}
    Switch 	Roku_left 		"left"			<arrow_left>			(Roku_navigation, Dev)		{http=">[*:POST:http://192.168.0.38:8060/keypress/left]", autoupdate="False"}
    Switch 	Roku_right 		"right"			<arrow_right>			(Roku_navigation, Dev)		{http=">[*:POST:http://192.168.0.38:8060/keypress/right]", autoupdate="False"}
    Switch 	Roku_ok 		"select"		<control_ok>			(Roku_navigation, Dev)		{http=">[*:POST:http://192.168.0.38:8060/keypress/select]", autoupdate="False"}
    Switch 	Roku_playpause 	"Play/Pause"	<arrow_pause>			(Roku_controls, Dev)		{http=">[*:POST:http://192.168.0.38:8060/keypress/play]", autoupdate="False"}
    Switch 	Roku_ff 		"Fast Forward"	<video>					(Roku_controls, Dev)		{http=">[*:POST:http://192.168.0.38:8060/keypress/fwd]", autoupdate="False"}
    Switch 	Roku_fw 		"Rewind"		<video>					(Roku_controls, Dev)		{http=">[*:POST:http://192.168.0.38:8060/keypress/rev]", autoupdate="False"}

Rule File:

rule "Remote Control Roku" when Item rokunavigate received command then if (receivedCommand==1) { sendCommand(Roku_back, ON)} else if (receivedCommand==2) { sendCommand(Roku_up, ON)} else if (receivedCommand==3) { sendCommand(Roku_home, ON)} else if (receivedCommand==4) { sendCommand(Roku_left, ON)} else if (receivedCommand==5) { sendCommand(Roku_ok, ON)} else if (receivedCommand==6) { sendCommand(Roku_right, ON)} else if (receivedCommand==7) {sendCommand(Roku_plex, ON) } else if (receivedCommand==8) { sendCommand(Roku_down, ON)} else if (receivedCommand==9) {sendCommand(Roku_porn, ON)} end

I would prefer switch case for the rule:

rule "Remote Control Roku"
when
    Item rokunavigate received command
then 
    switch (receivedCommand) {
        case  1:       Roku_back.sendCommand(ON)
        case  2:         Roku_up.sendCommand(ON)
        case  3:       Roku_home.sendCommand(ON)
        case  4:       Roku_left.sendCommand(ON)
        case  5:         Roku_ok.sendCommand(ON)
        case  6:      Roku_right.sendCommand(ON)
        case  7:       Roku_plex.sendCommand(ON)
        case  8:       Roku_down.sendCommand(ON)
        case  9:       Roku_porn.sendCommand(ON)
        case 10:         Roku_fw.sendCommand(ON)
        case 11:  Roku_playpause.sendCommand(ON)
        case 12:         Roku_ff.sendCommand(ON)
        default: logInfo ("Roku","Command {} not supported!",receivedCommand)
}
end

As you can see, for sendCommand I used the method instead of the action, this is due to the fact that there are some glitches with the action since ~ OH1.8.1

1 Like