With the release of OH3, and with the new shiny HTTP binding working very well, I spent a little time to update the OH2 rules setup from Roku Support with one using the HTTP binding and XPATH transform. Below is relatively copy/paste and seems to work pretty cleanly. No rules or scripts are necessary. I have this running on 7 Roku devices (2x are TVs) and it seems to have no issues.
Some notes in comparison to the OH2 version linked above:
-I have removed the keyboard for now. I just havenāt had a chance to mess with the Lit_ function in the API on this and I honestly never use it so I may just leave it out.
-Iām not a huge fan of the 1 second refresh timer. It has caused some visible load on the Rokuās. Iāve submitted [HTTP] Feature Request - Off Cycle Refresh & Agent String Ā· Issue #9265 Ā· openhab/openhab-addons Ā· GitHub as a hope to fix this. If I can trigger an off-cycle refresh, then I can dial the ānormalā refresh up higher.
-This method gets away from the ssdp concept from OH2. I found over time that ssdp wasnāt 100% reliable during times of network congestion and would occasionally lose a device. This assumes static IPs of your Rokuās.
-The first two lines on the sitemap (power/volume) are only applicable to the Roku TVs, not the physical ones. Also, some Roku TVs go into a deeper sleep than others. You will need to change offValue=āReadyā to whatever your off is being set to on POWERMODE for the switch to work properly. Yes I could do this with a transform map, but I donāt have a comprehensive list and in general you only have one āoffā for a given device.
Thing http:url:ROKU<SERIAL-NUMBER> [ baseURL="http://<IP-ADDRESS>:8060/" , commandMethod="POST" , refresh="1" ] {
Channels:
Type string : UDN "UDN" [ stateExtension="query/device-info" , stateTransformation="XPath://udn" , mode="READONLY" ]
Type string : SERIALNUMBER "Serial Number" [ stateExtension="query/device-info" , stateTransformation="XPath://serial-number" , mode="READONLY" ]
Type string : DEVICEID "Device ID" [ stateExtension="query/device-info" , stateTransformation="XPath://device-id" , mode="READONLY" ]
Type string : VENDORNAME "Vendor Name" [ stateExtension="query/device-info" , stateTransformation="XPath://vendor-name" , mode="READONLY" ]
Type string : MODELNAME "Model Name" [ stateExtension="query/device-info" , stateTransformation="XPath://model-name" , mode="READONLY" ]
Type string : MODELNUMBER "Model Number" [ stateExtension="query/device-info" , stateTransformation="XPath://model-number" , mode="READONLY" ]
Type string : SUPPORTSETHERNET "Supports Ethernet" [ stateExtension="query/device-info" , stateTransformation="XPath://supports-ethernet" , mode="READONLY" ]
Type string : WIFIMAC "Wifi MAC" [ stateExtension="query/device-info" , stateTransformation="XPath://wifi-mac" , mode="READONLY" ]
Type string : ETHERNETMAC "Ethernet MAC" [ stateExtension="query/device-info" , stateTransformation="XPath://ethernet-mac" , mode="READONLY" ]
Type string : NETWORKTYPE "Network Type" [ stateExtension="query/device-info" , stateTransformation="XPath://network-type" , mode="READONLY" ]
Type string : USERDEVICENAME "User Device Name" [ stateExtension="query/device-info" , stateTransformation="XPath://user-device-name" , mode="READONLY" ]
Type string : SOFTWAREVERSION "Software Version" [ stateExtension="query/device-info" , stateTransformation="XPath://software-version" , mode="READONLY" ]
Type string : SOFTWAREBUILD "Software Build" [ stateExtension="query/device-info" , stateTransformation="XPath://software-build" , mode="READONLY" ]
Type string : SECUREDEVICE "Secure Device" [ stateExtension="query/device-info" , stateTransformation="XPath://secure-device" , mode="READONLY" ]
Type string : POWERMODE "Power Mode" [ stateExtension="query/device-info" , stateTransformation="XPath://power-mode" , mode="READONLY" ]
Type switch : POWER "Power" [ stateExtension="query/device-info" , stateTransformation="XPath://power-mode" , onValue="PowerOn", offValue="Ready" , mode="READONLY" ]
Type string : APP "App" [ stateExtension="query/active-app" , stateTransformation="XPath://app" , mode="READONLY" ]
Type string : SCREENSAVER "Screen Saver" [ stateExtension="query/active-app" , stateTransformation="XPath://screensaver" , mode="READONLY" ]
Type string : LAUNCH "Launch" [ commandExtension="launch/%2$s" , mode="WRITEONLY" ]
Type string : KEYPRESS "Key Press" [ commandExtension="keypress/%2$s" , mode="WRITEONLY" ]
}
String ROKU3_<SERIAL-NUMBER>_serialnumber "Serial Number [%s]" { channel="http:url:ROKU<SERIAL-NUMBER>:SERIALNUMBER" }
String ROKU3_<SERIAL-NUMBER>_deviceid "Device ID [%s]" { channel="http:url:ROKU<SERIAL-NUMBER>:DEVICEID" }
String ROKU3_<SERIAL-NUMBER>_vendorname "Vendor Name [%s]" { channel="http:url:ROKU<SERIAL-NUMBER>:VENDORNAME" }
String ROKU3_<SERIAL-NUMBER>_modelname "Model Name [%s]" { channel="http:url:ROKU<SERIAL-NUMBER>:MODELNAME" }
String ROKU3_<SERIAL-NUMBER>_modelnumber "Model Number [%s]" { channel="http:url:ROKU<SERIAL-NUMBER>:MODELNUMBER" }
String ROKU3_<SERIAL-NUMBER>_supportsethernet "Supports Ethernet [%s]" { channel="http:url:ROKU<SERIAL-NUMBER>:SUPPORTSETHERNET" }
String ROKU3_<SERIAL-NUMBER>_wifimac "Wifi MAC [%s]" { channel="http:url:ROKU<SERIAL-NUMBER>:WIFIMAC" }
String ROKU3_<SERIAL-NUMBER>_ethernetmac "Ethernet MAC [%s]" { channel="http:url:ROKU<SERIAL-NUMBER>:ETHERNETMAC" }
String ROKU3_<SERIAL-NUMBER>_networktype "Network Type [%s]" { channel="http:url:ROKU<SERIAL-NUMBER>:NETWORKTYPE" }
String ROKU3_<SERIAL-NUMBER>_userdevicename "User Device Name [%s]" { channel="http:url:ROKU<SERIAL-NUMBER>:USERDEVICENAME" }
String ROKU3_<SERIAL-NUMBER>_softwareversion "Software Version [%s]" { channel="http:url:ROKU<SERIAL-NUMBER>:SOFTWAREVERSION" }
String ROKU3_<SERIAL-NUMBER>_softwarebuild "Software Build [%s]" { channel="http:url:ROKU<SERIAL-NUMBER>:SOFTWAREBUILD" }
String ROKU3_<SERIAL-NUMBER>_securedevice "Secure Device [%s]" { channel="http:url:ROKU<SERIAL-NUMBER>:SECUREDEVICE" }
String ROKU3_<SERIAL-NUMBER>_powermode "Power Mode [%s]" (gRokuPowerMode) { channel="http:url:ROKU<SERIAL-NUMBER>:POWERMODE" }
Switch ROKU3_<SERIAL-NUMBER>_powerstate "Power [%s]" { channel="http:url:ROKU<SERIAL-NUMBER>:POWER" }
String ROKU3_<SERIAL-NUMBER>_activeapp "App [%s]" { channel="http:url:ROKU<SERIAL-NUMBER>:APP" }
String ROKU3_<SERIAL-NUMBER>_screensaver "Screen Saver [%s]" { channel="http:url:ROKU<SERIAL-NUMBER>:SCREENSAVER" }
String ROKU3_<SERIAL-NUMBER>_launch "Launch [%s]" (gRokuLaunch) { channel="http:url:ROKU<SERIAL-NUMBER>:LAUNCH" }
String ROKU3_<SERIAL-NUMBER>_keypress "Key Press [%s]" (gRokuKeypres) { channel="http:url:ROKU<SERIAL-NUMBER>:KEYPRESS" }
Frame label="Roku TV" icon="house" {
Text item=ROKU3_<SERIAL-NUMBER>_status label=""
Switch item=ROKU3_<SERIAL-NUMBER>_keypress label="" mappings=['POWER'="Power"]
Switch item=ROKU3_<SERIAL-NUMBER>_keypress label="" mappings=['VOLUMEMUTE'="Mute",'VOLUMEUP'="VOL UP",'VOLUMEDOWN'="VOL DN"]
Switch item=ROKU3_<SERIAL-NUMBER>_keypress label="" mappings=['BACK'="Back",'HOME'="Home",'INFO'="Info"]
Switch item=ROKU3_<SERIAL-NUMBER>_keypress label="" mappings=['NULL'="--",'UP'="ā²",'NULL'="--"]
Switch item=ROKU3_<SERIAL-NUMBER>_keypress label="" mappings=['LEFT'="ā",'SELECT'="ā",'RIGHT'="āŗ"]
Switch item=ROKU3_<SERIAL-NUMBER>_keypress label="" mappings=['NULL'="--",'DOWN'="ā¼",'NULL'="--"]
Switch item=ROKU3_<SERIAL-NUMBER>_keypress label="" mappings=['REV'="āā",'PLAY'="āŗ||",'FWD'="āŗāŗ"]
Switch item=ROKU3_<SERIAL-NUMBER>_keypress label="" mappings=['INSTANTREPLAY'="Replay",'SEARCH'="Search"]
Switch item=ROKU3_<SERIAL-NUMBER>_keypress label="" mappings=['BACKSPACE'="Backspace",'ENTER'="Enter"]
Text label="Roku Apps" icon="office" {
Switch item=ROKU3_<SERIAL-NUMBER>_launch label="" icon="12" mappings=['12'="Netflix"]
Switch item=ROKU3_<SERIAL-NUMBER>_launch label="" icon="13842" mappings=['13842'="VUDU"]
Switch item=ROKU3_<SERIAL-NUMBER>_launch label="" icon="186362" mappings=['186362'="Movies Anywhere"]
Switch item=ROKU3_<SERIAL-NUMBER>_launch label="" icon="837" mappings=['837'="YouTube"]
Switch item=ROKU3_<SERIAL-NUMBER>_launch label="" icon="13535" mappings=['13535'="PLEX"]
Switch item=ROKU3_<SERIAL-NUMBER>_launch label="" icon="34376" mappings=['34376'="WatchESPN"]
Switch item=ROKU3_<SERIAL-NUMBER>_launch label="" icon="13" mappings=['13'="Amazon Video"]
}
Text label="Device Info" icon="office" {
Frame label="ROKU<SERIAL-NUMBER>" {
Text item=ROKU3_<SERIAL-NUMBER>_serialnumber
Text item=ROKU3_<SERIAL-NUMBER>_deviceid
Text item=ROKU3_<SERIAL-NUMBER>_vendorname
Text item=ROKU3_<SERIAL-NUMBER>_modelname
Text item=ROKU3_<SERIAL-NUMBER>_modelnumber
Text item=ROKU3_<SERIAL-NUMBER>_supportsethernet
Text item=ROKU3_<SERIAL-NUMBER>_wifimac
Text item=ROKU3_<SERIAL-NUMBER>_ethernetmac
Text item=ROKU3_<SERIAL-NUMBER>_networktype
Text item=ROKU3_<SERIAL-NUMBER>_userdevicename
Text item=ROKU3_<SERIAL-NUMBER>_softwareversion
Text item=ROKU3_<SERIAL-NUMBER>_softwarebuild
Text item=ROKU3_<SERIAL-NUMBER>_securedevice
Text item=ROKU3_<SERIAL-NUMBER>_powermode
Text item=ROKU3_<SERIAL-NUMBER>_activeapp
Text item=ROKU3_<SERIAL-NUMBER>_screensaver
}
}
}