Buttons to control openHAB

Thanks for sharing this Mark, I’ve adapted it and I think its right. I was using loads of if statements so ive converted to this - seems case is the way to do this, although the if statements worked fine

Heres my rule for my fridge mounted ZRC-90.

In thinking about this, you could actually use 1 button press to do both on and off quite easily right but just checking the state?

Case 6 is the funny one, i’ll test this when I’m home :slight_smile:

rule "Remotec ZRC-90 - Fridge"
when
    Item LivingRoom_Zrc_Remote received update
then
    var int sceneNumber = LivingRoom_Zrc_Remote.state as DecimalType

    switch (sceneNumber) {
        case 1.0 : {            // Button 1 short press
            logInfo("ZRC90-Fridge", "Remotec ZRC-90 Fridge Button 1 short press: " + sceneNumber)
            KitchenBarSw1.sendCommand(ON)
        }
        case 1.3 : {            // Button 1 double press
            logInfo("ZRC90-Fridge", "Remotec ZRC-90 Fridge 1 Button 2 Double press: " + sceneNumber)
            KitchenBarSw1.sendCommand(OFF)
        }
        case 2.0 : {            // Button 2 short press
            logInfo("ZRC90-Fridge", "Remotec ZRC-90 Fridge Button 2 short press: " + sceneNumber)
            KitchenSw1.sendCommand(ON)
        }
        case 2.3 : {            // Button 2 double press
            logInfo("ZRC90-Fridge", "Remotec ZRC-90 Fridge Button 2 double press: " + sceneNumber)
            KitchenSw1.sendCommand(OFF)
        }
        case 3.0 :  {           // Button 3 short press
            logInfo("ZRC90-Fridge", "Remotec ZRC-90 Fridge Button 3 short press: " + sceneNumber)
            BackEveSw1.sendCommand(ON)
        }
        case 3.3 : {            // Button 3 double press
            logInfo("ZRC90-Fridge", "Remotec ZRC-90 Fridge Button 3 double press: " + sceneNumber)
            BackEveSw1.sendCommand(OFF)
        }
        case 4.0 : {            // Button 4 short press
            logInfo("ZRC90-Fridge", "Remotec ZRC-90 Fridge Button 4 short press: " + sceneNumber)
            CarportSw1.sendCommand(ON)
        }
        case 4.3 :  {           // Button 4 double press
            logInfo("ZRC90-Fridge", "Remotec ZRC-90 Fridge Button 4 double press: " + sceneNumber)
            CarportSw1.sendCommand(OFF)
        }
        case 5.0 : {            // Button 5 short press
            logInfo("ZRC90-Fridge", "Remotec ZRC-90 Fridge Button 5 short press: " + sceneNumber)
            Aircon.sendCommand('AirconOn')
        }
        case 5.3 :  {           // Button 5 double press
            logInfo("ZRC90-Fridge", "Remotec ZRC-90 Fridge Button 5 double press: " + sceneNumber)
            Aircon.sendCommand('AirconOff')
        }
        case 6.0 : {            // Button 6 short press
            logInfo("ZRC90-Fridge", "Remotec ZRC-90 Fridge Button 6 short press: " + sceneNumber)
             if (Main_Zone_Power.state == OFF) {
               Main_Zone_Power.sendCommand('ON')
               Zone_1_Input.sendCommand('Spotify')
               spotify_current_device_id.sendCommand("f48564e5be42c184009e18b2d771af1a225d22c4")
               spotify_action.sendCommand('transfer_playback')
               spotify_action.sendCommand('play')
               }
             if (Main_Zone_Power.state == ON) {
               Zone_1_Input.sendCommand('Spotify')
               spotify_current_device_id.sendCommand("f48564e5be42c184009e18b2d771af1a225d22c4")
               spotify_action.sendCommand('transfer_playback')
               spotify_action.sendCommand('play')
               }
        }
       case 6.3 :  {           // Button 6 double press
            logInfo("ZRC90-Fridge", "Remotec ZRC-90 Fridge Button 6 double press: " + sceneNumber)
            Main_Zone_Power.sendCommand('OFF')
        }

    }
end

Sure. You could do something like this inside the case.

if (KitchenBarSw1.state == ON) {
    KitchenBarSw1.sendCommand(OFF)
} else if (KitchenBarSw1.state == OFF) {
    KitchenBarSw1.sendCommand(ON)
}
1 Like

Hi @mhilbush So given Kai close my post on the ESH forums, where exactly do changes need to be made to support swiping? I’m confused as to how to given it more support . Thanks

Sorry, I’m not really sure what to suggest.

@chris do you know if its the binding or the ESH framework that requires support for swiping on zwave devices? I’m still unclear where the issue resides.