How to map the button with exec command and BlackBeanControl

Hello friends.
I am new to openhab and have a problem that I don’t really understand, please help me.
I have 1 Broadlink mini 3.
Successfully installed: https://github.com/mjg59/python-broadlink and set up the control to turn off the TV when running manual commands.
In addition, I have learned many other commands in BlackBeanControl.ini file like Vol up, …
Installed addon exec bindings

Now how do I map the button in the sitemap with some command? For example:
item file: String TV_LIVINGROOM “TV”
sitemap file:

Frame label=“Tivi Samsung”{
Switch item = TV_LIVINGROOM label = “Power” mappings = [TV_POWER_ON = “On”, TV_POWER_OFF = “Off”]
Setpoint item=Tivi_Vol label=“Set vol” icon=temperature minValue=0 maxValue=100 step=10
}

How do I map the ON - OFF command and Value volume, in the sitemap with exec to execute the command I learned in BlackBeanControl.ini

please help me one example .map file in this case.

Thanks all, sory my English.

well the exec command can be difficult to get working usually for reasons that have nothing to do with OpenHAB (permissions and such). You might want to also check out the executeCommandLine method

example :

in your items files:

Switch Power_tv_amp "Power TV" ["Switchable"] {exec=">[ON:/usr/bin/python /etc/openhab2/scripts/BlackBeanControl/BlackBeanControl.py -c poweronTVsdj -d Rm3sdj] >[OFF:/usr/bin/python /etc/openhab2/scripts/BlackBeanControl/BlackBeanControl.py -c poweroffTVsdj -d Rm3sdj]"}

other example in rules file:

rule “Power tv sdj”
when
Item Power_tv_amp received command
then
if (receivedCommand == ON) {
executeCommandLine(“/usr/bin/python /etc/openhab2/scripts/BlackBeanControl/BlackBeanControl.py -c poweronYam -d Rm3sdj”)
if (now.getHourOfDay() >= 20 && Petitlampe1.state == OFF) {
Petitlampe1.sendCommand(ON)
}
} else if (receivedCommand == OFF) {
executeCommandLine(“/usr/bin/python /etc/openhab2/scripts/BlackBeanControl/BlackBeanControl.py -c poweroffYam -d Rm3sdj”)
}
end

1 Like

Please note this Item configuration is for exec binding version 1, and will not work for the version 2 that is usually installed in openHAB2. That uses things and channels instead.

Rule based Actions remain the same, though.

yes , I use the version 1 of exec binding on openhab 2.4 :slight_smile:

Thanks @Fiftiz.
i use exec on openhab 2.4 and setup ok one swich ON OFF. but to have many functions of a television or air conditioner. then they will be a lot of switch buttons. According to the reference on the forum, I found there were some comments about sitemaps and they were very convenient.
For example:
Text label = “Swing” icon = “AirCon” {
Selection item = AirCon_Mode mappings = [0 = “Auto”, 1 = "Cool", 2 = “Dry”, 3 = “Fan”]
}

How does the system know, when I choose Mode Auto from the sitemap, will launch the exec command I set it up with cooling mode.

in rules files

cas 0 : executeCommandLine … // cas 0 is mode Auto
cas 1 : executeCommandLine … // cas 1 is mode Cool

etc

thanks @Fiftiz i will try :slight_smile: