[SOLVED] Problem adapting existing blinds to OpenHab

I am new to OpenHab2 and want to control some existing blinds with a 433Mhz remote. The blind brand is Rollease Acmeda. I have a Raspberry pi with a 433 transmitter. I can record the codes etc

I have set up the following

Blind12.things
Thing exec:command:blind12 “Blind12” @ “Home”[
command="/home/pi/blinds.sh %2$s 12",
interval=0,
autorun=true]
Items

Blind12.items

// Blind Items

//String PlaceHolder “”
Rollershutter Blind12A “Blind12A”

Switch Blind12 “Blind12” { channel=“exec:command:blind12:run” }
String Blind12_input “Blind12_in” { channel=“exec:command:blind12:input” }
String Blind12_output “Blind12_out” { channel=“exec:command:blind12:output” }
Number Blind12_exit “Blind12_exit” { channel=“exec:command:blind12:exit” }
DateTime Blind12_lastExecution “Blind12_last” { channel=“exec:command:blind12:lastexecution” }

Blind12.rules (based on transmitter example)

import java.util.concurrent.locks.ReentrantLock

val ReentrantLock transmitter = new ReentrantLock

rule “Single Blind”
when
Item Blind12A changed
then

logInfo("Blinds", "Member " + triggeringItem.name + " to " + receivedCommand)

try {
  // Lock transmitter so other executed rules dont't use it at the same time.
  // Concurrent calls of the rule will wait till the resource is free again.
  transmitter.lock()

  // Set the command which should be executed to the output channel 
  // Auto trigger will then execute the Thing.
  if(receivedCommand == DOWN){
    Blind12_Input.sendCommand(“DOWN”)
  }else{
    Blind12_Input.sendCommand(“UP”)
  }

  // Wait for the command to complete
  //while(Remote_Send.state != OFF){
    //Thread::sleep(100)
  //}

  // Mulltiple trigger do not work if there is no break here
  // maybe external skript needs some time to properly free resources.
  Thread::sleep(400)
  logInfo("Blinds", Remote_Send_Out.state.toString.replaceAll("\r|\n"," ") )
}catch(Throwable t) {}
finally {
    // Free the resource for the next call.
    transmitter.unlock()
}

end

What I want to achieve is to be able to user the Rollershutter Blind12A Item to issue the command line for blind12. I hope to use the IOS app to control the blinds

I think the rule is ok but I cannot see how to make the UI work. The Blind12 Thing does present using the IOS app although I cannot enter values into the input field

What do you mean?
Are you using a sitemap?

My sitemap (sitemaps/Blinds.sitemaps)

sitemap Blinds label=“Blinds”
{
Frame label=“Blindsf”
{
Text item=PlaceHolder label="" icon=“none”
Switch item=Blind12A label=“Blind 12” mappings=[0=“UP”,1=“DOWN”,2=“STOP”]
}
}

Please use the code fences.
If you don’t do that, we can’t read your code and most of your double quote have changed to “bendy” ones…

  if(receivedCommand == "DOWN"){
    Blind12_Input.sendCommand("DOWN")
  }else{
    Blind12_Input.sendCommand("UP")
  }

Sitemap:

{
    Frame label="Blindsf" {
        Text item=PlaceHolder label="" icon="none"
        Selection item=Blind12A label="Blind 12" mappings=[0="UP",1="DOWN",2="STOP"]
    }
}

Thanks. Moved forward. sitemaps/Blinds.sitemaps should have been sitemaps/Blinds.sitemap

sitemap Blinds label="Blinds"
{
    Frame label="Blinds"
    {
        Text item=PlaceHolder label="" icon="none"
        Switch item=Blind12A label="Blind 12" mappings=[0="UP",1="DOWN",2="STOP"]
    }
}

I now have the GUI working well enough.

However the rules do not trigger when the Blind12A item is changed. The rule is

rule "SingleBlind"
  when
     Item Blind12A received command
  then

    logInfo("Blinds", "Member " + triggeringItem.name + " to " + receivedCommand)
      if(receivedCommand == DOWN){
        Blind12_input.sendCommand("DOWN")
      }
      else if(receivedCommand == STOP){
        Blind12_input.sendCommand("STOP")
      }else{
        Blind12_input.sendCommand("UP")
      }

 end

The log shows

15:31:57.233 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'Blind12A' received command DOWN
15:31:57.503 [INFO ] [smarthome.event.ItemStateChangedEvent] - Blind12A changed from 0 to 100

The logInfo

If you want to run the Rule when the Item changes, use the changed trigger

Item Blind12A changed

Thank you for the suggestion but unfortunately it did not make a difference. There is still no evidence in the log of the rule being fired. The rules are being refreshed.

I have also tried the example for 433Mhz control with the exec binding. That rule also does not trigger

I have the feeling that there is something simple wrong

If the item changing state? Look in events.log to verify.

Yes the item is changing.
I have just done a restart of openhab2. And of course the rules are now being triggered. I did see other threads that implied that Thread::sleep(100) can cause issues with rule execution so I am hoping that is the problem. If so maybe the 433Mhz exec example should be updated to reflect a better model for waiting

The solves were

  1. sitemaps are in file extension .sitemap (no s)
  2. The rule threads were blocked. A restart cleared the block. Possibly due to Thread::sleep

A Thread::sleep(100) by itself is unlikely to caused this problem unless you can end up with lots and lots of that rule trying to run at the same time.

could you elaborate on your setup? are your rollerease blinds the new ones or the old ones??

thanks. wife just bought them and learning about integration… did you try using the acmeda hub?

thanks…

I’m also interested in this, I tried to duplicate the RF signal for my RollEase Blind and was unable to do so. I know it isn’t directly you question but could you please explain how you were able to get the code?
Regards,

Simon

I had made some attempts to get the RF codes while I was also doing the UI stuff. Unfortunately life got in the way and I have not progressed.

Regards