I would like to use a rule (or any other method) to setup a “Safety” check for someone hitting the wrong button on the UI. I have some motorized blinds that I built and due to how it is physically installed, I have a limit switch on the closing of the blinds but not the open. Therefore the hardware on the blinds could try and keeping opening the blinds even when they are open and ruin the motor or belt. What I would like to do is to have openhab check the position of the blinds and if they are already open don’t allow the open command to be sent otherwise pass the command through.
I have tried this will a rule using received command and sendcommand but that seemed to put me in an infinite loop. I have also tried setting receivedCommand equal to the value but that gives me erros in the logs.
Basically I would like to do something like this:
//******************************************
// Check if ok to open / close blinds
//******************************************
rule "Bedroom Blinds Check"
when
Item BedroomBlinds changed
then
if (receivedCommand == DOWN) {
// If command to close and they are open, pass through command
if ((BedroomBlinds.state as DecimalType) == 0) {
sendCommand(BedroomBlinds, DOWN)
}
// Otherwise, post and error
else {
postUpdate(BedroomBlindsError, "Not at beginning")
}
}
else if (receivedCommand == UP) {
// If command to open and they are open always pass command because of limit switch
sendCommand(BedroomBlinds, UP)
}
else {
// Always pass STOP commands
sendCommand(BedroomBlinds, STOP)
}
end
I guess one method would be to use a proxy item that receives the UI command and then passes the actuall command to the blinds, but wondering if I am missing something trivial here.
Thanks!