(SOLVED) Touching a button twice to send the actual command that is configured to that button

I am using habpanel and I like it so far. I do have a strange issue with it.

56

If I push button 1(ID) it will send the command 21 to my tv. That works
If I push button 2 (bbc first) it will send command 21 again to my tv.
If I push button 2 again it will send command 25 to my tv which is good.

To be short with every button I touch I will have to touch it twice, because it first sent the previous command and with the second push it will send the actual command that is configured on that button.

Version openhab is 2.5

Can you post your item definition? And how is OH sending the update to the TV is it items or rules?

InOmThnx in advance for spending some time on this issue:grinning::smiley:
It uses rules. The issue is the same if i use the basic UI.

sitemap

[Frame label=“Zenders”{
Switch item=GC100_IR_ITV label=“Power ITV[]” mappings=[GC100_IR_ITV_POWER_ON=“ON”, GC100_IR_ITV_POWER_OFF=“OFF”]
Selection item=TV_Controller icon=screen label=“TV Zenders” mappings=[ID=“ID”, BBCFIRST=“BBCFIRST”, MTV=“MTV”, NPO0=“NPO1”, NPO2=“NPO2”, NPO3=“NPO3”, RTL4=“RTL4”, RTL5=“RTL5”, SBS6=“SBS6”, RTL7=“RTL7”, RTL8=“RTL8”, SBS9=“SBS9”, VERONICA=“VERONICA”, NET5=“NET5”, RTLZ=“RTLZ”, BBCONE=“BBC ONE”, BBCTWO=“BBC TWO”, CARTNET=“CARTOON”, DISCOVERY=“DISCOVERY”, MTV=“MTV”,SPIKE=“SPIKE”, FOX=“FOX”, TLC=“TLC”, DISNEY=“DISNEY”, XITE=“XITE”, EEN=“EEN”, CANVAS=“CANVAS”, KETNET=“KETNET”, VICELAND=“VICELAND”, INSIGHT=“INSIGHT”,24KITCHEN=“24KITCHEN”, ZENDERMAAND=“ZenderMaand”, HISTORY=“HISTORY”, NICKELODEON=“NICKELODEON”, LOVENATURE=“LOVENATURE”, EUROSPORT=“EUROSPORT”]
Selection item=TV_Controller icon=receiver label=“Radio Zenders” mappings=[538=“538”, RVERONICA=“VERONICA”, SKYRADIO=“SKYRADIO”,ARROW=“ARROW”,RADIO2=“NPO RADIO2”, RADIO3=“NPO RADIO3”, SLAM=“SLAM”, QMUSIC=“QMUSIC”, DECIBEL=“DECIBEL”]

RULES I have removed some entries to make it smaller

rule “TV Control”
when
Item TV_Controller received command
then
switch (TV_Controller.state.toString) {
case “NPO1”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
}
case “RTLZ”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
}
case “ComedyCentral”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_2”)
}
case “SPIKE”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_3”)
}
case “FOX”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_4”)
}
case “DISCOVERY”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_5”)
}
case “NATGEO”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_6”)
}
case “TLC”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_7”)
}
case “DISNEY”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_8”)
}
case “SBS9”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_9”)
}
case “MTV”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_2”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_0”)
}
case “ID”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_2”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
}
case “XITE”:{
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_2”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_2”)
}
case “EEN”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_2”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_9”)
}
case “CANVAS”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_3”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_0”)
}
case “KETNET”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_3”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
}
case “HISTORY”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_3”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_2”)
}
case “NICKELODEON”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_3”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_3”)
}
case “LOVENATURE”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_3”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_4”)
}
case “538”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_8”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_0”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_9”)
}
case “RADIO1”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_8”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_0”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
}
case “RADIO2”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_8”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_0”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_2”)
}
case “RADIO3”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_8”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_0”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_3”)
}
case “SKYRADIO”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_8”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_0”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_8”)
}
case “RVERONICA”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_8”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_9”)
}
case “ARROW”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_8”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_4”)
}
case “QMUSIC”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_8”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
}
case “DECIBEL”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_8”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_2”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_2”)
}
case “SLAM”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_8”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_1”)
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_6”)
}
case “ITV_OK”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_OK”)
}
case “ITV_CHUP”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_CHUP”)
}
case “ITV_CHDO”: {
GC100_IR_ITV.sendCommand(“GC100_IR_ITV_CHDOWN”)
}
}

Items proxy item

String WatchTvControl
String TV_Controller

Transform sends IR commands to tv and that works

GC100_IR_ITV_1 = 0000 0049 0000 0025 0012 0024 0024 0024 0012 0012 0024 0024 0024 0024 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0024 0024 0012 12CE 0012 0024 0024 0024 0012 0012 0024 0024 0024 0024 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0024 0024 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0024 0024 0012 1618
GC100_IR_ITV_2 = 0000 0049 0000 0023 0012 0024 0024 0024 0012 0012 0024 0024 0024 0024 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0024 0024 0024 12E0 0012 0024 0024 0024 0012 0012 0024 0024 0024 0024 0012 0012 0012 0012 0012 0012 0012 0012 0012 0012 0024 0024 0012 0012 0012 0012 0012 0012 0012 0012 0024 0024 0024 1618

image
image

Here you have a timing race condition.
A command sent to an Item does NOT immediately affect its state.
Explainer -
In some cases, it may never affect it; or there could be a delay while some real device carries out the command and then responds. For some Items the eventual resulting state might have little to with the command anyway, example a roller UP could give position 65%.
Where the Item has no device binding, openHAB by default does a magic trick called autoupdate. Like a device binding, this listens for commands and predicts what the likely state will be. That can optionally be turned off, but for your Item it will be working - but it still takes time to do it.
Look in your events.log and you will see this happening.

This is a fundamental part of how openHAB works, it is worth you understanding the difference between commands and states.

So, in the case of your button press, the rule triggers immediately on receiving the command, quickly reads the state … but this is still the old last state.

The fix is easy, because there is a special implicit variable for a command trigger called receivedCommand. Here, that’s what you are really interested in, not the state.

when
   Item TV_Controller received command
then
   switch (receivedCommand.toString) {

So with my experience with doing some playing around with a Roku remote and sending HTTP API commands I noticed on my dashboard side of things the switches were not really an ON/OFF type of scenario it just turned into a button to hit repeatedly until the outcome was reached. Later I refined my work to include a postUpdate command to force the state change without actually sending a command to the Roku.

Back to your scenario have you checked your /rest/items/TV_Controller (as one example) to know that when you change the channel if its the same value forcing you to have to hit the button a second time to have an update made?
Also as another troubleshooting method you can watch the event.log file when you hit the button to see what OH is processing from an item/rule standpoint to get a better idea of what is causing this.

that did the trick. thnx you all for your replies:+1::+1::+1: