[SOLVED] How to set up switch mapping other than ON/OFF

Hi there,

I’m sorry if this question has been asked before but I can’t find anything similar. I’m planning to put all remote control button of my air conditioner to OpenHAB sitemap. Right now i’m able to put in only ON/OFF for Switch item. It won’t take other values than ON/OFF.

May I know how and what item should I use if say I wanna use mappings = On, Off, 23C, 24C, 25C, Fan1, Fan2, Fan3 and such? I have tried item=string but still not working. Appreciate anyone could shed some light and thank you in advanced

Current config:


default.sitemap
Switch item=bedroomac label= "Bedroom Air Cond" mappings=[ON= "Turn On" , OFF= "Turn Off" ]
default.rules
rule "bedroomac"
        when
            Item bedroomac received command
        then
        if (receivedCommand==ON ) {
            executeCommandLine("python /usr/share/openhab2/exec/BlackBeanControl.py -c room_ac_23")
        }
        else if (receivedCommand==OFF ) {
            executeCommandLine("python /usr/share/openhab2/exec/BlackBeanControl.py -c room_ac_off")
        }
end

You definitely need to use a String item.
In this case your rule needs to look like this:

rule “bedroomac”
when
Item bedroomac received command
then
if (receivedCommand=="on" ) {

Please note that you need to use “” for a string to be compared.

1 Like

Hello, here is my setup for AC (Infra Red controlled)

SITEMAP

sitemap Ir_server label="Telecommande InfraRouge"
{
Frame label="DAIKIN" {
Switch item=Daikin_Send mappings=[1="Envoi",0="OFF"]
Switch item=Daikin_Mode mappings=[1="CLIM", 2="CHAUFFAGE", 3="VENTILATEUR"]
Switch item=Daikin_Temp mappings=[18="18",19="19",20="20",21="21",22="22",23="23",24="24"]
Switch item=Daikin_FanSpeed mappings=[1="1",2="2",3="3",4="4",5="5"]
Switch item=Daikin_HSwing mappings=[1="ON",0="OFF"]
Switch item=Daikin_VSwing mappings=[1="ON",0="OFF"]
}
}

ITEMS

String Daikin_Send "Envoi commande Daikin" <switch> (gAll,gDaikin)
String Daikin_Mode "Mode" <heating> (gAll,gDaikin)
String Daikin_Temp "Température" <temperature> (gAll,gDaikin)
String Daikin_FanSpeed "Vitesse" <fan> (gAll,gDaikin)
String Daikin_HSwing "Balayage Horiz" <flow> (gAll,gDaikin)
String Daikin_VSwing "Balayage Vert" <smoke> (gAll,gDaikin)

RULE

// DAIKIN
rule "rDaikin"
when
	Member of gDaikin received command 
then 
logInfo("rule rDaikin", "command "+receivedCommand)
val DOnOff=Daikin_Send.state.toString()
val Dmode=Daikin_Mode.state.toString()
val Dtemp=Daikin_Temp.state.toString()
val DFanSpeed=Daikin_FanSpeed.state.toString()
val DHSwing=Daikin_HSwing.state.toString()
val DVSwing=Daikin_VSwing.state.toString()
val Dparam ="1,"+DOnOff+","+DFanSpeed+","+Dmode+","+Dtemp+","+DVSwing+","+DHSwing
logInfo("rule rDaikin", "Param Envoyé "+Dparam)
publish("broker", "ir_server/send",Dparam)
//Daikin_Send.postUpdate(NULL)
end
1 Like

Can you just add ways to link items with exec?