Need help: Exec binding - different script per item button

Hi guys,

I’m having some trouble working out how to run a script per button/mapping in my sitemap. I’d like to be able to have a single item in my sitemap with mappings for + and - that allow me to run a different script per + or - button and ideally have that script run each time the button is pressed.

I’ve tried the following:

Things:

Thing exec:command:TV_GF_Vol_Up "TV" [ command="python /home/openhabian/addons/BlackBeanControl/BlackBeanControl.py -c LG_TV_Vol_Up -d Lounge", timeout=15, interval=0, autorun=true ]
Thing exec:command:TV_GF_Vol_Down "TV" [ command="python /home/openhabian/addons/BlackBeanControl/BlackBeanControl.py -c LG_TV_Vol_Down -d Lounge", timeout=15, interval=0, autorun=true ]

Items:

String TV_GF_Volume "TV" { channel="ON:exec:command:TV_GF_Vol_Up:input, OFF:exec:command:TV_GF_Vol_Down:input" }

Sitemap:

Switch item=TV_GF_Volume label="Volume" mappings=[OFF="-", ON="+"]

All that happens when I press the + or - button is that each of the commands is run one after the other.
Also when I press either of the buttons multiple times I don’t get the command running a second time, it only runs when changing states.

I have a workaround with a single button per + and - with a rule that triggers the exec binding, but it feels very messy. I’m no OH pro but I feel like the above should work.

Thanks in advance for your help.

The exec 2.x binding is a little quirky in how it works. I was trying to help someone else awhile back with a similar problem and I think they had a problem where updating the input channel did not cause the script to run.

Another work around is a rule and executeCommandLine.

1 Like

Thanks for the suggestion rlkoshak. I have something like what you mentioned working with a virtual (unlinked) item and a rule that uses the executeCommandLine function but I was really hoping for something a little more elegant :slight_smile: