Onkyo binding NETUSB list handling

Tags: #<Tag:0x00007fe73366d240> #<Tag:0x00007fe73366d0d8>

Has anyone figured out how to process lists when a NETUSB source like vTuner is selected? In particular I would like to be able to select stations from the Openhab GUI without having to see the receiver video output. Currently I have found the following:

  1. The #NLS command will return a window of the current list of up to 10 items. The items have an attribute and can be folders so the menu structure can have hierarchy.
  2. The #NLSL command will select an item from the window of the current list. Selecting a folder items descends the hierarchy and changes the current list to that in the folder.
  3. The NETUSB_OP_UP and NETUSB_OP_DOWN commands will scroll the window within the list if it has more than 10 items.
  4. The NETUSB_OP_RETURN command will ascend one level higher in the hierarchy and changes the list to that of the parent.

I’m new with openhab and haven’t figured out how to put all this together into a working GUI. The list items appear to be separated by newline characters and each item is proceeded by it’s encoding type, position in the list, and it’s attribute. All of these are ASCII characters, but some processing of the returned text is required.

Regards,

~petev

Is the List element in the sitemap still supported under 1.8? I tried to use it to separate the result of the onkyo #NLS command, but it is not behaving correctly at all. It completely messes up the rendering of whatever frame I place it into.

~petev

I tried the following configuration:

ITEMS

String onkyoNETList “List [%s]” (Onkyo1) {onkyo="*:onkyo1:#NLS"}
String onkyoNETList0 “1 [%s]” (Onkyo1)
String onkyoNETList1 “2 [%s]” (Onkyo1)
String onkyoNETList2 “3 [%s]” (Onkyo1)
String onkyoNETList3 “4 [%s]” (Onkyo1)
String onkyoNETList4 “5 [%s]” (Onkyo1)
String onkyoNETList5 “6 [%s]” (Onkyo1)
String onkyoNETList6 “7 [%s]” (Onkyo1)
String onkyoNETList7 “8 [%s]” (Onkyo1)
String onkyoNETList8 “9 [%s]” (Onkyo1)
String onkyoNETList9 “10 [%s]” (Onkyo1)

SITEMAP

  		Frame label="Navigation" {
  			Switch		item=onkyoNETReturn
  			Switch		item=onkyoNETUp
  			Switch		item=onkyoNETDown
  			Selection	item=onkyoNETService mappings=[0="Media Server (DLNA)", 1=Favorite, 2=vTuner, 3=SIRIUS, 6="Last.fm", 14="TuneIn Radio"]
  			Selection	item=onkyoNETSelectList mappings=[0="1", 1="2", 2="3", 3="4", 4="5", 5="6", 6="7", 7="8", 8="9", 9="10"]
  		}
  		Frame label="List" {
  			Text		item=onkyoNETList0
  			Text		item=onkyoNETList1
  			Text		item=onkyoNETList2
  			Text		item=onkyoNETList3
  			Text		item=onkyoNETList4
  			Text		item=onkyoNETList5
  			Text		item=onkyoNETList6
  			Text		item=onkyoNETList7
  			Text		item=onkyoNETList8
  			Text		item=onkyoNETList9
  		}

RULES

import org.openhab.core.library.types.*
import org.openhab.core.library.items.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

import java.util.concurrent.locks.ReentrantLock
import java.util.List
import java.util.ArrayList

var ReentrantLock onkyoLock = new java.util.concurrent.locks.ReentrantLock()

val List onkyoList = newArrayList (
onkyoNETList0,
onkyoNETList1,
onkyoNETList2,
onkyoNETList3,
onkyoNETList4,
onkyoNETList5,
onkyoNETList6,
onkyoNETList7,
onkyoNETList8,
onkyoNETList9
)

val String onkyoIndex = “0123456789”

/**

  • This rule processes Onkyo list updates and stores each one to a separate string element.
    */

rule "Update List Item"
when
Item onkyoNETList changed
then
onkyoLock.lock()
try {
logDebug(“onkyo.rules”, onkyoNETList.state.toString())

  	var String state = onkyoNETList.state.toString()
  	var i = 0
  	while(i  < 10) {
  		if(state.charAt(1) == onkyoIndex.charAt(i)){
  			postUpdate(onkyoList.get(i), state.substring(3))				
  		}
  		i = i + 1
  	}
  } finally{
       onkyoLock.unlock()
  }

end

However, I found from the log that the receiver is sending the status update events too fast for openhab to process. I would see log lines from the binding about processing each status update line, and lines from the rule about processing each update, but they were not in sync. Usually the rule would end up being called 10 times with the value of the last update. Sometimes some intermediate values would be processed. Here is some of the relevant output:

LOGFILE

xml.transform.stream.StreamSource@18d2b4a’
01:34:44.994 [DEBUG] [.b.onkyo.internal.OnkyoBinding:413 ] - Cannot convert value ‘NLSU1-Recent Launches’ to data type class org.openhab.core.library.items.NumberItem
01:34:44.998 [DEBUG] [.b.onkyo.internal.OnkyoBinding:334 ] - Received status update ‘NLSU2-My Added Stations’ from device 192.168.100.65
01:34:45.000 [DEBUG] [.b.onkyo.internal.OnkyoBinding:413 ] - Cannot convert value ‘NLSU2-My Added Stations’ to data type class org.openhab.core.library.items.NumberItem
01:34:45.002 [DEBUG] [.b.onkyo.internal.OnkyoBinding:413 ] - Cannot convert value ‘NLSU2-My Added Stations’ to data type class org.openhab.core.library.items.NumberItem
01:34:45.004 [DEBUG] [.b.onkyo.internal.OnkyoBinding:334 ] - Received status update ‘NLSU3-Local Stations’ from device 192.168.100.65
01:34:45.006 [DEBUG] [.b.onkyo.internal.OnkyoBinding:413 ] - Cannot convert value ‘NLSU3-Local Stations’ to data type class org.openhab.core.library.items.NumberItem
01:34:45.018 [DEBUG] [.b.onkyo.internal.OnkyoBinding:413 ] - Cannot convert value ‘NLSU3-Local Stations’ to data type class org.openhab.core.library.items.NumberItem
01:34:45.019 [DEBUG] [.b.onkyo.internal.OnkyoBinding:334 ] - Received status update ‘NLSU4-Stations By Genre’ from device 192.168.100.65
01:34:45.022 [DEBUG] [.b.onkyo.internal.OnkyoBinding:413 ] - Cannot convert value ‘NLSU4-Stations By Genre’ to data type class org.openhab.core.library.items.NumberItem
01:34:45.023 [DEBUG] [.b.onkyo.internal.OnkyoBinding:413 ] - Cannot convert value ‘NLSU4-Stations By Genre’ to data type class org.openhab.core.library.items.NumberItem
01:34:45.025 [DEBUG] [.b.onkyo.internal.OnkyoBinding:334 ] - Received status update ‘NLSU5-Stations By Location’ from device 192.168.100.65
01:34:45.028 [DEBUG] [.b.onkyo.internal.OnkyoBinding:413 ] - Cannot convert value ‘NLSU5-Stations By Location’ to data type class org.openhab.core.library.items.NumberItem
01:34:45.030 [DEBUG] [.b.onkyo.internal.OnkyoBinding:413 ] - Cannot convert value ‘NLSU5-Stations By Location’ to data type class org.openhab.core.library.items.NumberItem
01:34:45.032 [DEBUG] [.b.onkyo.internal.OnkyoBinding:334 ] - Received status update ‘NLSU6-New Stations’ from device 192.168.100.65
01:34:45.036 [DEBUG] [.b.onkyo.internal.OnkyoBinding:413 ] - Cannot convert value ‘NLSU6-New Stations’ to data type class org.openhab.core.library.items.NumberItem
01:34:45.038 [DEBUG] [.b.onkyo.internal.OnkyoBinding:413 ] - Cannot convert value ‘NLSU6-New Stations’ to data type class org.openhab.core.library.items.NumberItem
01:34:45.040 [DEBUG] [.b.onkyo.internal.OnkyoBinding:334 ] - Received status update ‘NLSU7-Most Popular Stations’ from device 192.168.100.65
01:34:45.042 [DEBUG] [.b.onkyo.internal.OnkyoBinding:413 ] - Cannot convert value ‘NLSU7-Most Popular Stations’ to data type class org.openhab.core.library.items.NumberItem
01:34:45.044 [DEBUG] [.b.onkyo.internal.OnkyoBinding:413 ] - Cannot convert value ‘NLSU7-Most Popular Stations’ to data type class org.openhab.core.library.items.NumberItem
01:34:45.046 [DEBUG] [.b.onkyo.internal.OnkyoBinding:334 ] - Received status update ‘NLSU8-Search Stations’ from device 192.168.100.65
01:34:45.049 [DEBUG] [.b.onkyo.internal.OnkyoBinding:413 ] - Cannot convert value ‘NLSU8-Search Stations’ to data type class org.openhab.core.library.items.NumberItem
01:34:45.053 [DEBUG] [.b.onkyo.internal.OnkyoBinding:334 ] - Received status update ‘NLSU9-Buzz’ from device 192.168.100.65
01:34:45.054 [DEBUG] [m.r.internal.engine.RuleEngine:305 ] - Executing rule 'Update List Item’
01:34:45.055 [DEBUG] [.b.onkyo.internal.OnkyoBinding:413 ] - Cannot convert value ‘NLSU9-Buzz’ to data type class org.openhab.core.library.items.NumberItem
01:34:45.059 [DEBUG] [.b.onkyo.internal.OnkyoBinding:413 ] - Cannot convert value ‘NLSU9-Buzz’ to data type class org.openhab.core.library.items.NumberItem
01:34:45.095 [DEBUG] [m.r.internal.engine.RuleEngine:305 ] - Executing rule 'Update List Item’
01:34:45.112 [DEBUG] [m.r.internal.engine.RuleEngine:305 ] - Executing rule 'Update List Item’
01:34:45.128 [DEBUG] [m.r.internal.engine.RuleEngine:305 ] - Executing rule 'Update List Item’
01:34:45.144 [DEBUG] [enhab.model.script.onkyo.rules:38 ] - U4-Stations By Genre
01:34:45.147 [DEBUG] [.i.s.XsltTransformationService:89 ] - transformation resulted in '
'
01:34:45.148 [DEBUG] [.o.b.http.internal.HttpBinding:197 ] - transformed response is '
'
01:34:45.149 [DEBUG] [.o.b.http.internal.HttpBinding:262 ] - Couldn’t create state of type ‘class org.openhab.core.library.items.NumberItem’ for value '
'
01:34:45.149 [DEBUG] [m.r.internal.engine.RuleEngine:305 ] - Executing rule 'Update List Item’
01:34:45.167 [DEBUG] [m.r.internal.engine.RuleEngine:305 ] - Executing rule 'Update List Item’
01:34:45.184 [DEBUG] [m.r.internal.engine.RuleEngine:305 ] - Executing rule 'Update List Item’
01:34:45.200 [DEBUG] [m.r.internal.engine.RuleEngine:305 ] - Executing rule 'Update List Item’
01:34:45.217 [DEBUG] [m.r.internal.engine.RuleEngine:305 ] - Executing rule 'Update List Item’
01:34:45.232 [DEBUG] [m.r.internal.engine.RuleEngine:305 ] - Executing rule 'Update List Item’
01:34:45.244 [DEBUG] [ore.internal.items.ItemUpdater:73 ] - Received update of a not accepted type (StringType) for item Weather_Temperature
01:34:45.369 [DEBUG] [enhab.model.script.onkyo.rules:38 ] - U9-Buzz
01:34:45.582 [DEBUG] [enhab.model.script.onkyo.rules:38 ] - U9-Buzz
01:34:45.805 [DEBUG] [enhab.model.script.onkyo.rules:38 ] - U9-Buzz
01:34:46.002 [DEBUG] [enhab.model.script.onkyo.rules:38 ] - U9-Buzz

Next I tried the following with no rule:

ITEMS

String onkyoNETList0 “1 [%s]” (Onkyo1) {onkyo=":onkyo1:#NLSU0"}
String onkyoNETList1 “2 [%s]” (Onkyo1) {onkyo="
:onkyo1:#NLSU1"}
String onkyoNETList2 “3 [%s]” (Onkyo1) {onkyo=":onkyo1:#NLSU2"}
String onkyoNETList3 “4 [%s]” (Onkyo1) {onkyo="
:onkyo1:#NLSU3"}
String onkyoNETList4 “5 [%s]” (Onkyo1) {onkyo=":onkyo1:#NLSU4"}
String onkyoNETList5 “6 [%s]” (Onkyo1) {onkyo="
:onkyo1:#NLSU5"}
String onkyoNETList6 “7 [%s]” (Onkyo1) {onkyo=":onkyo1:#NLSU6"}
String onkyoNETList7 “8 [%s]” (Onkyo1) {onkyo="
:onkyo1:#NLSU7"}
String onkyoNETList8 “9 [%s]” (Onkyo1) {onkyo=":onkyo1:#NLSU8"}
String onkyoNETList9 “10 [%s]” (Onkyo1) {onkyo="
:onkyo1:#NLSU9"}

However, I found that the binding must only be looking at the first three characters of the command “NLS” as the items were updated with every line sent, not just the line intended for them. Is there any way the binding could be modified to match the whole command instead of just a portion of it? Note that the command is never sent by openhab, the receiver sends the status update events automatically. So maybe the binding needs some type of indication that it is an input and some processing expression like the HTTP binding has.

~petev