Switch representing a Rollershutter for Alexa

Hi,

I wont to control my rollershutter with the new Alexa Skill. This are represented by HomeKit Items, wich don’t represent rollershutters.

My idea is now to simulate an switch with rules. The rollershutter should work like normal, but an “alias switch” should represent the state of the shutter. If the switch recives a command (ON or OFF), the shutter should move.

At the moment I have this two rules. But they behavior like a loop, if I move the shutter for example to 95% close state.
The first rule works exactly like expected, but the second creates the loop…

import java.util.concurrent.locks.ReentrantLock
var java.util.concurrent.locks.ReentrantLock lock  = new java.util.concurrent.locks.ReentrantLock()

// Items:
// Rollershutter   ZWave_Shutter_Schlafzimmer          "Rollladen Schlafzimmer"
// Switch          Alias_Switch_Rolladen_Schlafzimmer  "Rollladen Schlafzimmer"

rule "Rolladen Schlafzimmer Movement"
    when
        Item ZWave_Shutter_Schlafzimmer changed
    then
        logInfo("Rolladen Schlafzimmer Movement", "der Rolladen hat sich bewegt")

        lock.lock()
        try {
            if (ZWave_Shutter_Schlafzimmer.state < 5){
                sendCommand(Alias_Switch_Rolladen_Schlafzimmer, OFF)
                logInfo("Rolladen Schlafzimmer Movement", "Rolladen ist oben - Alias Switch -> off")
            }else{
                sendCommand(Alias_Switch_Rolladen_Schlafzimmer, ON)
                logInfo("Rolladen Schlafzimmer Movement", "Rolladen ist oben - Alias Switch -> on")
            }
        } finally{
            lock.unlock()
        }
end

rule "Rolladen Schlafzimmer Alias Switch"
    when
        Item Alias_Switch_Rolladen_Schlafzimmer received command
    then
        logInfo("Rolladen Schlafzimmer Alias Switch", "Switch received command")

        lock.lock()
        try {
            if (Alias_Switch_Rolladen_Schlafzimmer.state == ON){
                sendCommand(ZWave_Shutter_Schlafzimmer, 100)
                logInfo("Rolladen Schlafzimmer Alias Switch", "Rolladen wird herunter gefahren")
            }else{
                sendCommand(ZWave_Shutter_Schlafzimmer, 0)
                logInfo("Rolladen Schlafzimmer Alias Switch", "Rolladen wird hoch gefahren")
            }
        } finally{
            lock.unlock()
        }
end

Has anybody souch a setup? Any suggestions so solve my problem?

PS: Openhab2, Zwave binding for shutters

Greats
Julian

Hi,

thanks for this hint. This works.

Regards
Julian

1 Like

Hi,

I have a led light that I want to switch of with with a seperate swtich item, and the brightness I want to controll with another item - still I only would like to use one item in alexa ( “Switch on lamp”; “Set lamp to 30%”). Is it possible to modified the rule above, such that if the input from Alexa is yes or no then the response go to the switch item, and if the input from alexa is % then the respons should go to the led ligth controller item?

BR
Patrik

The workaround works great (for “set to xx %”, “on” and “off”). Is there also an idea for “stop”?
And eventually for “open”/“close” instead of on/off?

As far as I remember this is already possible for English language, but not yet for others …

For the moment, I use “set to 0%” for “open,/up”, “set to 100%” for “close/down” and “set to 50%” as special command for “stop”, all via rules:

rule "Rollo1 Küchentür über Alexa bedienen"
when
  Item Shutter1_Alexa received update
then
  if(SystemStarted_delayed.state == ON)
  {
    // 0% is open, 100% closed, 50% stop (workaround....)
    //logInfo("Rollershutter Loginfo", "Shutter1_Alexa Küchentür cmd: " + Shutter1_Alexa.state.toString)
    if(Shutter1_Alexa.state == 50)
    {
      //logInfo("Rollershutter Loginfo", "Shutter1_Alexa STOP ")
      Shutter1.sendCommand(STOP)
    
    }
    else
    {
      Shutter1.sendCommand(Shutter1_Alexa.state.toString) // Küchentürrollo command weiterreichen
    }
    
  }
end

Same here :grinning: