@mhilbush Thanks for all the help. The binding seems to be working OK once I manually added the 'thing" (still confused about “things”). It is working from my sitemap.
I have another question. I would like to use the binding in a rule to send channel numbers to my cable STB.
This is my config:
items:
String Cisco_Raw_Send { channel="globalcache:itachFlex:000C1EE09F5B:ir-m1c3", autoupdate=false}
sitemap:
Switch item=Cisco_Channel mappings=[518="Global",514="CTV",597="Food"]
MAP file:
Cisco_DIGIT_0 = 58000,1,1,191,191,46,141,46,141,46,46,46,141,46,141,46,141,46,46,46,46,46,141,46,141,46,46,46,46,46,46,46,141,46,46,46,46,46,46,46,141,46,141,46,46,46,46,46,141,46,2150
Cisco_DIGIT_1 = 58000,1,1,191,191,46,141,46,141,46,46,46,141,46,141,46,46,46,46,46,46,46,46,46,141,46,46,46,46,46,46,46,141,46,46,46,46,46,141,46,141,46,141,46,141,46,46,46,141,46,2150
Cisco_DIGIT_2 = 58000,1,1,191,191,46,141,46,141,46,46,46,141,46,141,46,141,46,46,46,46,46,46,46,141,46,46,46,46,46,46,46,141,46,46,46,46,46,46,46,141,46,141,46,141,46,46,46,141,46,2150
Cisco_DIGIT_3 = 58000,1,1,191,191,46,141,46,141,46,46,46,141,46,141,46,46,46,141,46,46,46,46,46,141,46,46,46,46,46,46,46,141,46,46,46,46,46,141,46,46,46,141,46,141,46,46,46,141,46,2150
Cisco_DIGIT_4 = 58000,1,1,191,191,46,141,46,141,46,46,46,141,46,141,46,141,46,141,46,46,46,46,46,141,46,46,46,46,46,46,46,141,46,46,46,46,46,46,46,46,46,141,46,141,46,46,46,141,46,2150
Cisco_DIGIT_5 = 58000,1,1,191,191,46,141,46,141,46,46,46,141,46,141,46,46,46,46,46,141,46,46,46,141,46,46,46,46,46,46,46,141,46,46,46,46,46,141,46,141,46,46,46,141,46,46,46,141,46,2150
Cisco_DIGIT_6 = 58000,1,1,191,191,46,141,46,141,46,46,46,141,46,141,46,141,46,46,46,141,46,46,46,141,46,46,46,46,46,46,46,141,46,46,46,46,46,46,46,141,46,46,46,141,46,46,46,141,46,2150
Cisco_DIGIT_7 = 58000,1,1,191,191,46,141,46,141,46,46,46,141,46,141,46,46,46,141,46,141,46,46,46,141,46,46,46,46,46,46,46,141,46,46,46,46,46,141,46,46,46,46,46,141,46,46,46,141,46,2150
Cisco_DIGIT_8 = 58000,1,1,191,191,46,141,46,141,46,46,46,141,46,141,46,141,46,141,46,141,46,46,46,141,46,46,46,46,46,46,46,141,46,46,46,46,46,46,46,46,46,46,46,141,46,46,46,141,46,2150
Cisco_DIGIT_9 = 58000,1,1,191,191,46,141,46,141,46,46,46,141,46,141,46,46,46,46,46,46,46,141,46,141,46,46,46,46,46,46,46,141,46,46,46,46,46,141,46,141,46,141,46,46,46,46,46,141,46,2150
Rule:
rule "Change TV Channel via Cisco STB"
when
Item Cisco_Channel changed
then
logInfo("TV Channel", "TV Channel change received to: " + Cisco_Channel.state)
val channel = (Cisco_Channel.state as DecimalType).intValue
val num1 = (channel/100).intValue
val num2 = ((channel - (num1*100)) /10).intValue
val num3 = (channel - (num1*100) - (num2*10)).intValue
logInfo("TV Channel", "TV Channel numbers are: " + num1 + num2 + num3)
val ArrayList<Integer> numarray = newArrayList(num1,num2,num3)
logInfo("TV Channel", "TV Channel array is: " + numarray + " of size: " + numarray.size)
numarray.forEach[ number |
val number_st = number.toString
logInfo("TV Channel", "Sending Number: " + number_st)
switch(number_st) {
case "0": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_0")
logInfo("TV Channel", "Transmiting Number: 0")
case "1": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_1")
logInfo("TV Channel", "Transmiting Number: 1")
case "2": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_2")
logInfo("TV Channel", "Transmiting Number: 2")
case "3": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_3")
logInfo("TV Channel", "Transmiting Number: 3")
case "4": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_4")
logInfo("TV Channel", "Transmiting Number: 4")
case "5": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_5")
logInfo("TV Channel", "Transmiting Number: 5")
case "6": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_6")
logInfo("TV Channel", "Transmiting Number: 6")
case "7": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_7")
logInfo("TV Channel", "Transmiting Number: 7")
case "8": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_8")
logInfo("TV Channel", "Transmiting Number: 8")
case "9": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_9")
logInfo("TV Channel", "Transmiting Number: 9")
}
Thread::sleep(250) //delay for number to be sent
]
logInfo("TV Channel", "Finished Sending")
end
This is the output from when I press the button on the interface
2016-11-25 16:50:04.686 [DEBUG] [ntime.internal.engine.RuleEngineImpl] - Executing rule 'Change TV Channel via Cisco STB'
2016-11-25 16:50:04.687 [INFO ] [se.smarthome.model.script.TV Channel] - TV Channel change received to: 514
2016-11-25 16:50:04.688 [INFO ] [se.smarthome.model.script.TV Channel] - TV Channel numbers are: 514
2016-11-25 16:50:04.688 [INFO ] [se.smarthome.model.script.TV Channel] - TV Channel array is: [5, 1, 4] of size: 3
2016-11-25 16:50:04.688 [INFO ] [se.smarthome.model.script.TV Channel] - Sending Number: 5
2016-11-25 16:50:04.688 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Change TV Channel via Cisco STB': Unhandled parameter types: [null, org.eclipse.xtext.xbase.interpreter.impl.DefaultEvaluationContext@38a0a0e9, org.eclipse.xtext.util.CancelIndicator$1@399ecc65]
It doesn’t like the “sendCommand(Cisco_Raw_Send, “Cisco_DIGIT_X”)” commands. I also tried it without the quotes around Cisco_DIGIT_X. I was fairly sure this would work, ie send to a String item connected to an ir channel (same channel that works for sitemap items), this would map to an IR code, and be sent. I don’t know what the error means though.
Any idea what is wrong? can you send an ir code via rule?
Thanks,
OK - stupid me, I had the syntax of my switch statement wrong. It occurred to me that I was doing exactly this elsewhere in my rules - and it worked fine, and sure enough - not your problem, my syntax was wrong.
I need braces in a switch statement. anyway, fixed rule is:
rule "Change TV Channel via Cisco STB"
when
Item Cisco_Channel changed
then
logInfo("TV Channel", "TV Channel change received to: " + Cisco_Channel.state)
val channel = (Cisco_Channel.state as DecimalType).intValue
val num1 = (channel/100).intValue
val num2 = ((channel - (num1*100)) /10).intValue
val num3 = (channel - (num1*100) - (num2*10)).intValue
logInfo("TV Channel", "TV Channel numbers are: " + num1 + num2 + num3)
val ArrayList<Integer> numarray = newArrayList(num1,num2,num3)
logInfo("TV Channel", "TV Channel array is: " + numarray + " of size: " + numarray.size)
numarray.forEach[ number |
val number_st = number.toString
logInfo("TV Channel", "Sending Number: " + number_st)
switch(number_st) {
case "0": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_0")
case "1": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_1")
case "2": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_2")
case "3": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_3")
case "4": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_4")
case "5": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_5")
case "6": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_6")
case "7": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_7")
case "8": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_8")
case "9": sendCommand(Cisco_Raw_Send, "Cisco_DIGIT_9")
default: logInfo("TV Channel", "Unknown number: " + number_st)
}
Thread::sleep(250) //delay for number to be sent
]
logInfo("TV Channel", "Finished Sending")
end
Which changes channel perfectly!