[SOLVED] Rollershutter via modbus to Wago 750-881

Hi!

I´m new in Openhab and modbus, but i already got a lot of things to work.

I was able to setup the connection between OpenHab and my Wago 750-881 via Modbus.
Also the connection from Alexa via myopenhab and my Wago is working already. (only for testing at the moment to get familiar with openhab and modbus protokoll)

Now i would like to bring this all to a Wife friendly “production” status. :wink:

All the logic is located at the Wago SPS and i only have to send bool (bits for on or off) to my Wago SPS.
The logic in my SPS are able to understand short press and long press.
Short press is for turning on and of the lights and open and close the rollershutters.
Long press is for dimming the lights or let the rullershutters drive until i release the physical button at home.

Now i would like to replace the normal switch items in openhab with rullershutter items but i don´t understand how to setup the rules for that.

I added following item:

Rollershutter Rollershutter_buero "Büro Rollo" (EG_Buero, EG) ["Switchable"]

in the sitemap:

     Text label="Büro Test" {
        Switch item=Rollershutter_buero label="Büro Rollo" icon="rollershutter-30" mappings=[UP="Hoch", STOP="X", DOWN="Runter"]
      }

in rules (because of missing knowledge i tried to adapt a rule found in an other post here):

rule "Buero Rollershutter"
when
    Item Rollershutter_buero received command
then
    switch(receivedCommand.toString.toUpperCase){
        case "HOCH": {
           channel="modbus:data:Wago:coils:Bit44:switch"
        }
        case "STOP": {
           channel="modbus:data:Wago:coils:Bit44:switch"
        }
        case "DOWN": {
           channel="modbus:data:Wago:coils:Bit2:switch"
        }      
    }
end

sertainly this not working… what would be the correct syntax for the rules?
Is it possible to use the channels directly or do i have to adress “virtual” switches?

the rule which i actually are using for the normal switch items:

rule "Buero auf"
when 
Item Buero_auf changed to ON
then
Thread::sleep(250)
sendCommand(Buero_auf,OFF)
end

rule "Buero zu"
when 
Item Buero_zu changed to ON
then
Thread::sleep(250)
sendCommand(Buero_zu,OFF)
end

The more important thing is to send short press to the SPS… great would be to be able to send also long press… but this is a “nice to have” thing.

I hope i was able to describe my problem good enough with my poor english… :wink:
If you need more informations please let me know i will try to deliver it.

Thank you all very much in advance and greetings from Vienna!

rule "Buero Rollershutter"
when
    Item Rollershutter_buero received command
then
    switch (receivedCommand){
        case UP: {
            ItemLinkedToChannelBit44.sendCommand(ON) // channel="modbus:data:Wago:coils:Bit44:switch"
        }
        case STOP: {
           ItemLinkedToChannelBit44.sendCommand(OFF) // channel="modbus:data:Wago:coils:Bit44:switch"
        }
        case DOWN: {
           ItemLinkedToChannelBit2.sendCommand(ON) // channel="modbus:data:Wago:coils:Bit2:switch"
        }      
    }
end

Thank you very much for fast response! :+1:

I think there is still something missing.

I tried it and get following errors:

2019-01-07 12:43:10.436 [ome.event.ItemCommandEvent] - Item 'Rollershutter_buero' received command DOWN
2019-01-07 12:43:10.470 [vent.ItemStateChangedEvent] - Rollershutter_buero changed from 0 to 100
==> /var/log/openhab2/openhab.log <==
2019-01-07 12:43:16.292 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Buero Rollershutter': The name 'ItemLinkedToChannelBit2' cannot be resolved to an item or type; line 29, column 12, length 23

You need to create an item linked to that channel. Name it what you want, this was an example

ok… i understand…i tried it, but it don´t work…

This is what i have configured at the moment.
The normal switches are working properly!

.things (only a short clipping to understand):

Bridge poller coils [ start=12528, length=43, refresh=5000, type="coil" ] {
    Thing data Bit1 [ readStart="12528", readValueType="bit" , writeStart="12528", writeValueType="bit", writeType="coil"]
    Thing data Bit2 [ readStart="12529", readValueType="bit" , writeStart="12529", writeValueType="bit", writeType="coil"]
    Thing data Bit3 [ readStart="12530", readValueType="bit" , writeStart="12530", writeValueType="bit", writeType="coil"]
    Thing data Bit4 [ readStart="12531", readValueType="bit" , writeStart="12531", writeValueType="bit", writeType="coil"]
    Thing data Bit5 [ readStart="12532", readValueType="bit" , writeStart="12532", writeValueType="bit", writeType="coil"]

items:

Switch Buero_auf   "Büro auf" (EG_Buero, EG) [ "Switchable" ] { channel="modbus:data:Wago:coils:Bit44:switch" }
Switch Buero_zu    "Büro zu"  (EG_Buero, EG) [ "Switchable" ] { channel="modbus:data:Wago:coils:Bit2:switch" }
Number Buero_Pos    "Büro Pos. [%.0f]" (EG_Buero, EG) { channel="modbus:data:Wago:inputRegistersRoll:B_Pos:number" }
Rollershutter Rollershutter_buero
Rollershutter Rollershutter_buero_up   ["Switchable"] { channel="modbus:data:Wago:coils:Bit44:switch" }
Rollershutter Rollershutter_buero_down   ["Switchable"] { channel="modbus:data:Wago:coils:Bit42:switch" }

sitemap:

itemap modbus label="Modbus" {
  Frame label="Rolläden" {
      Text item=Buero_Pos label="Büro" icon="rollershutter-30"  {
        Switch item=Buero_auf   label="Büro" mappings=[ON="Auf"]
        Switch item=Buero_zu     label="Büro" mappings=[ON="Zu"]
        Text item=Buero_Pos icon="rollershutter-30" label="Büro Pos"
      }
      Text label="Büro Test" {
        Switch item=Rollershutter_buero label="Büro Rollo" icon="rollershutter-30" mappings=[UP="Hoch", STOP="X", DOWN="Runter"]
      }

rules:

rule "Buero auf"
when 
Item Buero_auf changed to ON
then
Thread::sleep(250)
sendCommand(Buero_auf,OFF)
end

rule "Buero zu"
when 
Item Buero_zu changed to ON
then
Thread::sleep(250)
sendCommand(Buero_zu,OFF)
end

rule "Buero Rollershutter"
when
    Item Rollershutter_buero received command
then
    switch (receivedCommand){
        case UP: {
            Rollershutter_buero_up.sendCommand(ON) // channel="modbus:data:Wago:coils:Bit44:switch"
        }
        case STOP: {
           Rollershutter_buero_up.sendCommand(ON) // channel="modbus:data:Wago:coils:Bit44:switch"
        }
        case DOWN: {
           Rollershutter_buero_down.sendCommand(ON) // channel="modbus:data:Wago:coils:Bit2:switch"
        }      
    }
end

The normal switches are working fine… but the rollershutter is not working… what do i still miss here?
And is it also possible to integrate that after 250ms the “on” state is automatic is switched to “off”? or is this not nessesary in case of the rollershutter item? is this only on as long i hold the button on the app?

I don’t have experience with modbus
But you don’t have a Bit44 thing

Anyone else?

yes… as i wrote… this .things i posted above are only a short cutout to keep the post shorter…

but here is the whole list of the modbus things:

Bridge modbus:tcp:Wago [ host="10.0.0.33", port=502, id=1 ] {
// Inputregister lesen
Bridge poller inputRegisters [ start=12308, length=2, refresh=30000, type="input" ] {
    Thing data Float1 [ readStart="12308", readValueType="float32_swap"]
    }
// Coil write / read
Bridge poller inputRegistersRoll [ start=12310, length=2, refresh=5000, type="input" ] {
    Thing data B_Pos [ readStart="12310", readValueType="float32_swap" ]
    }
Bridge poller coils [ start=12528, length=43, refresh=5000, type="coil" ] {
    Thing data Bit1 [ readStart="12528", readValueType="bit" , writeStart="12528", writeValueType="bit", writeType="coil"]
    Thing data Bit2 [ readStart="12529", readValueType="bit" , writeStart="12529", writeValueType="bit", writeType="coil"]
    Thing data Bit3 [ readStart="12530", readValueType="bit" , writeStart="12530", writeValueType="bit", writeType="coil"]
    Thing data Bit4 [ readStart="12531", readValueType="bit" , writeStart="12531", writeValueType="bit", writeType="coil"]
    Thing data Bit5 [ readStart="12532", readValueType="bit" , writeStart="12532", writeValueType="bit", writeType="coil"]
    Thing data Bit6 [ readStart="12533", readValueType="bit" , writeStart="12533", writeValueType="bit", writeType="coil"]
    Thing data Bit7 [ readStart="12534", readValueType="bit" , writeStart="12534", writeValueType="bit", writeType="coil"]
    Thing data Bit8 [ readStart="12535", readValueType="bit" , writeStart="12535", writeValueType="bit", writeType="coil"]
    Thing data Bit9 [ readStart="12536", readValueType="bit" , writeStart="12536", writeValueType="bit", writeType="coil"]
    Thing data Bit10 [ readStart="12537", readValueType="bit" , writeStart="12537", writeValueType="bit", writeType="coil"]
    Thing data Bit11 [ readStart="12538", readValueType="bit" , writeStart="12538", writeValueType="bit", writeType="coil"]
    Thing data Bit12 [ readStart="12539", readValueType="bit" , writeStart="12539", writeValueType="bit", writeType="coil"]
    Thing data Bit13 [ readStart="12540", readValueType="bit" , writeStart="12540", writeValueType="bit", writeType="coil"]
    Thing data Bit14 [ readStart="12541", readValueType="bit" , writeStart="12541", writeValueType="bit", writeType="coil"]
    Thing data Bit15 [ readStart="12542", readValueType="bit" , writeStart="12542", writeValueType="bit", writeType="coil"]
    Thing data Bit16 [ readStart="12543", readValueType="bit" , writeStart="12543", writeValueType="bit", writeType="coil"]
    Thing data Bit17 [ readStart="12544", readValueType="bit" , writeStart="12544", writeValueType="bit", writeType="coil"]
    Thing data Bit18 [ readStart="12545", readValueType="bit" , writeStart="12545", writeValueType="bit", writeType="coil"]
    Thing data Bit19 [ readStart="12546", readValueType="bit" , writeStart="12546", writeValueType="bit", writeType="coil"]
    Thing data Bit20 [ readStart="12547", readValueType="bit" , writeStart="12547", writeValueType="bit", writeType="coil"]
    Thing data Bit21 [ readStart="12548", readValueType="bit" , writeStart="12548", writeValueType="bit", writeType="coil"]
    Thing data Bit22 [ readStart="12549", readValueType="bit" , writeStart="12549", writeValueType="bit", writeType="coil"]
    Thing data Bit23 [ readStart="12550", readValueType="bit" , writeStart="12550", writeValueType="bit", writeType="coil"]
    Thing data Bit24 [ readStart="12551", readValueType="bit" , writeStart="12551", writeValueType="bit", writeType="coil"]
    Thing data Bit25 [ readStart="12552", readValueType="bit" , writeStart="12552", writeValueType="bit", writeType="coil"]
    Thing data Bit26 [ readStart="12553", readValueType="bit" , writeStart="12553", writeValueType="bit", writeType="coil"]
    Thing data Bit27 [ readStart="12554", readValueType="bit" , writeStart="12554", writeValueType="bit", writeType="coil"]
    Thing data Bit28 [ readStart="12555", readValueType="bit" , writeStart="12555", writeValueType="bit", writeType="coil"]
    Thing data Bit29 [ readStart="12556", readValueType="bit" , writeStart="12556", writeValueType="bit", writeType="coil"]
    Thing data Bit30 [ readStart="12557", readValueType="bit" , writeStart="12557", writeValueType="bit", writeType="coil"]
    Thing data Bit31 [ readStart="12558", readValueType="bit" , writeStart="12558", writeValueType="bit", writeType="coil"]
    Thing data Bit32 [ readStart="12559", readValueType="bit" , writeStart="12559", writeValueType="bit", writeType="coil"]
    Thing data Bit33 [ readStart="12560", readValueType="bit" , writeStart="12560", writeValueType="bit", writeType="coil"]
    Thing data Bit34 [ readStart="12561", readValueType="bit" , writeStart="12561", writeValueType="bit", writeType="coil"]
    Thing data Bit35 [ readStart="12562", readValueType="bit" , writeStart="12562", writeValueType="bit", writeType="coil"]
    Thing data Bit36 [ readStart="12563", readValueType="bit" , writeStart="12563", writeValueType="bit", writeType="coil"]
    Thing data Bit37 [ readStart="12564", readValueType="bit" , writeStart="12564", writeValueType="bit", writeType="coil"]
    Thing data Bit38 [ readStart="12565", readValueType="bit" , writeStart="12565", writeValueType="bit", writeType="coil"]
    Thing data Bit39 [ readStart="12566", readValueType="bit" , writeStart="12566", writeValueType="bit", writeType="coil"]
    Thing data Bit40 [ readStart="12567", readValueType="bit" , writeStart="12567", writeValueType="bit", writeType="coil"]
    Thing data Bit41 [ readStart="12568", readValueType="bit" , writeStart="12568", writeValueType="bit", writeType="coil"]
    Thing data Bit42 [ readStart="12569", readValueType="bit" , writeStart="12569", writeValueType="bit", writeType="coil"]
    Thing data Bit43 [ readStart="12570", readValueType="bit" , writeStart="12570", writeValueType="bit", writeType="coil"]
    Thing data Bit44 [ readStart="12571", readValueType="bit" , writeStart="12571", writeValueType="bit", writeType="coil"]
    }
}

Does the rule trigger?
What do you see in the logs when you trigger the rule?

When i press the “Runter” button on the Switch this is written to the logfile:

2019-01-07 13:43:42.088 [ome.event.ItemCommandEvent] - Item 'Rollershutter_buero_down' received command ON
2019-01-07 13:43:42.104 [nt.ItemStatePredictedEvent] - Rollershutter_buero_down predicted to become NULL
2019-01-07 13:44:13.171 [ome.event.ItemCommandEvent] - Item 'Rollershutter_buero' received command DOWN
2019-01-07 13:44:13.200 [ome.event.ItemCommandEvent] - Item 'Rollershutter_buero_down' received command ON
2019-01-07 13:44:13.207 [nt.ItemStatePredictedEvent] - Rollershutter_buero_down predicted to become NULL

That’s odd, something to do with your binding config I guess. I don’t know sorry.
The rule works. You need a modbus expert.

I dont know if it would change anything, I´m no modbus expert. But first look I Noticed the length=43. Shouldn´t it be length=44 ? You have set up 44 adresses, but only read 43.

shame on me! i found a typo in my config… :wink:
it was a paste&copy error…

Yes you are right… but it worked with the normal switches… but i changed it to 44 now…

It is working now, but not completly.

Now i have the items Rollershutter_up and Rollershutter_down.

Via Rules i am matching UP to bit2 and DOWN to bit44. (like physical Switches in my house)
If i press Rauf (=UP) or Runter (=DOWN) this bits are set to True in the SPS.

How can i implement that UP or DOWN are going to “OFF” after 250ms?
The “STOP” Button is not nessesary, (I will delete this binding later on) because if the state is set to OFF after 250ms then a second press to UP or Down will stop the rullershutter. (logic in the Wago SPS)

Also it seems that the position of the rollershutter is going directly from 100 to 0 and back in one step… is it possible to write the actual status of the shutter to the rollershuter item? (buero_pos have the real position of the shutter)

250ms or 1s will do. Because there are different answers depending on the timing required

max. 250ms because a longer “press” on the physical or virtual button will be identified as a long press. 150ms is also ok. :wink:

Ok:

A rule

rule "reset rollershutter commands"
when
    Item Rollershutter_buero_up received command ON or
    Item Rollershutter_buero_down received command ON
then
    createTimer(now.plusMillis(250), [ |
        triggeringItem.postUpdate(OFF)
    ])
end

i implented your rule but i didn´t put it to OFF.

The OFF commando itself would be working because is see it when i press the “X” (STOP) of the Switch.

With “UP” i set Rollershutter_up to ON and with Stop is set Rollershutter_up to OFF and i see it in the SPS that the Flag is going from true to false when i press stop “X”.

Switch item=Rollershutter_buero label="Büro Rollo" icon="rollershutter-30" mappings=[UP="Hoch", STOP="X", DOWN="Runter"]
Rule "Buero Rollershutter"
when
    Item Rollershutter_buero received command
then
    switch (receivedCommand){
        case UP: {
            Rollershutter_buero_up.sendCommand(ON) // channel="modbus:data:Wago:coils:Bit44:switch"
        }
        case STOP: {
           Rollershutter_buero_up.sendCommand(OFF) // channel="modbus:data:Wago:coils:Bit44:switch"
        }
        case DOWN: {
           Rollershutter_buero_down.sendCommand(ON) // channel="modbus:data:Wago:coils:Bit2:switch"
        }      
    }
end```

Can I see the log, please?

2019-01-07 15:00:22.610 [ome.event.ItemCommandEvent] - Item 'Rollershutter_buero' received command DOWN
2019-01-07 15:00:22.625 [vent.ItemStateChangedEvent] - Rollershutter_buero changed from 0 to 100
2019-01-07 15:00:22.655 [ome.event.ItemCommandEvent] - Item 'Rollershutter_buero_down' received command ON
2019-01-07 15:00:23.273 [vent.ItemStateChangedEvent] - Rollershutter_buero_down changed from 0 to 100
2019-01-07 15:01:04.607 [vent.ItemStateChangedEvent] - Rollershutter_buero_down changed from 100 to 0

Ok, add some debug log:

rule "reset rollershutter commands"
when
    Item Rollershutter_buero_up received command ON or
    Item Rollershutter_buero_down received command ON
then
    logInfo("STARTING TIMER :", triggeringItem.name.toString)
    createTimer(now.plusMillis(250), [ |
        logInfo("TIMER EXECUTE", triggeringItem.name.toString)
        triggeringItem.postUpdate(OFF)
    ])
end

Try that and post the logs

ok… it seems that the timer is not triggered because there is no log for it.

2019-01-07 15:10:57.930 [ome.event.ItemCommandEvent] - Item 'Rollershutter_buero' received command DOWN
2019-01-07 15:10:57.938 [vent.ItemStateChangedEvent] - Rollershutter_buero changed from 0 to 100
2019-01-07 15:10:57.950 [ome.event.ItemCommandEvent] - Item 'Rollershutter_buero_down' received command ON
2019-01-07 15:11:02.811 [vent.ItemStateChangedEvent] - Rollershutter_buero_down changed from 0 to 100
2019-01-07 15:11:03.039 [vent.ItemStateChangedEvent] - Buero_Pos changed from 0.0 to 18.823530197143555
2019-01-07 15:11:08.192 [vent.ItemStateChangedEvent] - Buero_Pos changed from 18.823530197143555 to 40.0
2019-01-07 15:11:13.359 [vent.ItemStateChangedEvent] - Buero_Pos changed from 40.0 to 61.960784912109375
2019-01-07 15:11:18.567 [vent.ItemStateChangedEvent] - Buero_Pos changed from 61.960784912109375 to 83.52941131591797
2019-01-07 15:11:23.711 [vent.ItemStateChangedEvent] - Buero_Pos changed from 83.52941131591797 to 100.0
2019-01-07 15:11:38.866 [vent.ItemStateChangedEvent] - Rollershutter_buero_down changed from 100 to 0