Rollershutters need your help

Hi all.

My Setup:
Raspberry PI 3 with 433 mhz transmitter
Openenhabian

Whats working:
I am able to let the rollershutters go UP and DOWN with console.

I open the console and enter this command:

sudo ./fernotron-control/FernotronSend 7111111…31241

(the … stand for a lot more numbers)

I enter the sudo password and they go up and down. AWESOME.

Now i would like to integrate them into my openhab2 HABPanel and/or BasicUI but it does not work on both of them.

My code is the following:

rollershutter.items

Switch rollershutter_1_A <rollershutter>
Switch rollershutter_2_A <rollershutter>
Switch rollcontrol { channel="exec:command:rollcontrol:run" }
String rollcontrol_Args { channel="exec:command:rollcontrol:input"}
String rollcontrol_Out { channel="exec:command:rollcontrol:output" }

rollershutter.rules

rule "rollershutter_1_A"
  when
    Item rollershutter_1_A received command
  then
     if(receivedCommand == UP){
        rollcontrol_Args.sendCommand("71111...241")
     }else if(receivedCommand == STOP){
        rollcontrol_Args.sendCommand("71111...3141")
     }else if(receivedCommand == DOWN){
        rollcontrol_Args.sendCommand("71111...222")
     }
end


rule "rollershutter_2_A"
  when
    Item rollershutter_2_A received command
  then
     if(receivedCommand == UP){
        rollcontrol_Args.sendCommand("711111116....222")
     }else if(receivedCommand == STOP){
        rollcontrol_Args.sendCommand("711111116....322")
     }else if(receivedCommand == DOWN){        rollcontrol_Args.sendCommand("7111111...122")
     }
end

Thats how i edited the sudoers file

User privilege specification

root ALL=(ALL:ALL) ALL
openhab ALL=NOPASSWD: /fernotron-control/
openhabian ALL=NOPASSWD: /fernotron-control/

It get the following errors in the log file
2017-10-24 13:34:09.922 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at ‘items/rollershutter_2_A’ with an invalid status value ‘DOWN’.
2017-10-24 13:34:10.095 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at ‘items/rollershutter_2_A’ with an invalid status value ‘DOWN’.
2017-10-24 13:34:12.352 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at ‘items/rollershutter_2_A’ with an invalid status value ‘UP’.
2017-10-24 13:34:12.534 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at ‘items/rollershutter_2_A’ with an invalid status value ‘UP’.

And when i click the button which i programmed like this
openhabshuttererror

it get this error in log file

2017-10-24 13:36:49.569 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at ‘items/rollershutter_2_A’ with an invalid status value ‘UP’.
2017-10-24 13:36:49.942 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at ‘items/rollershutter_2_A’ with an invalid status value ‘DOWN’.

@rlkoshak @Josar

You guys helped me a lot with your links and posts. Do you see a mistake in it?

A switch item has only ON and OFF as valid states (and NULL as initial state while boot/until first correct command)
You have to change the switch items rollershutter_1_A and rollershutter_2_A bo be rollershutter items:

Rollershutter rollershutter_1_A "Shutter 1 A" //no need to define the icon, as 
Rollershutter rollershutter_2_A "Shutter 2 A" //<rollershutter> is default for 
                                              //Rollershutter items

Please be aware that sudo will display a message, the first time a command is successfully used. This is for every user. You have to affirm this message, or sudo will never(!) work.
So, to use sudo successfully for user openhab, you have to login as user openhab, start sudo and affirm the warning:

sudo su -s /bin/bash openhab
  (password for using sudo as normal user is requested)
sudo ls (dummy command... you could use any command
  (sudo is displaying it's message, type <enter> to affirm)
exit

Afaik you have to define the whole path and command (without parameters) in /etc/sudoers:

openhab ALL=(ALL) NOPASSWD: /usr/bin/fernotron-control/FernotronSend

(given the path is /usr/bin/)

In question of the rule, you could use a switch case structure:

rule "rollershutter_1_A"
when
    Item rollershutter_1_A received command
then
    switch (receivedCommand) {
       case UP:   rollcontrol_Args.sendCommand("71111...241")
       case STOP: rollcontrol_Args.sendCommand("71111...3141")
       case DOWN: rollcontrol_Args.sendCommand("71111...222")
   }
end

Awesome Thank you. Gonna try it right now :+1::+1::+1:

@Udo_Hartmann
Do i have to change every “switch” to “rollershutter” ? or just in the items file?

forr example in the rule file

rule "rollershutter_1_A"
when
    Item rollershutter_1_A received command
then
    rollershutter (receivedCommand) {
       case UP:   rollcontrol_Args.sendCommand("71111...241")
       case STOP: rollcontrol_Args.sendCommand("71111...3141")
       case DOWN: rollcontrol_Args.sendCommand("71111...222")
   }
end

Now i messed this system up. I can only connect with SSH. The IPADDRESS:8080 is down :frowning:

Did not work for me anyway.

BTW do i have to add openhab or openhabian when i use the openhabian system

use openhabian:8080 …

does not work. i can connect with ssh but i messed something up. when i open chrome its saying website not found.

edit its working again. dont know why

edit2: YEEEEEEEEEEEEES everything is working now. Had to change every switch to a rollershutter. thaaank you :slight_smile:

Right now i have the problem that sometimes the rollershutters dont move when the command is send. The solution is to resend the command.

  1. Question) Is there a possibilty to send the command with ignoring the state of the rollershutter. So if openhab thinks that its DOWN 100% that it resends the command ignoring the DOWN state?!

  2. Question) Whats the best way to solve this issue? how can i send the command two times? Like… rollershutter receives command UP and than send the UP command two times?

Noone?

@toto

case UP:   
// wait for previous command to complete, state will be NULL if not used before or ON while command is executed
      while(rollcontrol.state != OFF){
         Thread::sleep(500)
      }
rollcontrol_Args.sendCommand("71111...241")
// wait for the command to complete
      while(rollcontrol.state != OFF){
         Thread::sleep(500)
      }
//Send again
rollcontrol_Args.sendCommand("71111...241")

No guarantee for typos, written on my phone. But concept should be clear.

1 Like