Integrate Siemens Logo (plclogo) in OpenHAB 2

Hey,

I have used Rollershutter for my Garage and it worked. So i have altert it for your usecase.
I think you use this Frickelzeugs Rollo-UDF. This means that the status number means 0=closed=100% and 2=Open=0%
I have commented out the part where I use sthe Stop button vor the “Zwischen Position” it is ur decision to use it.

*.things
Thing pulse    Rollo_Terasse_Tuer_Auf 		[ block="VB2.0", pulse=400 ]
Thing pulse    Rollo_Terasse_Tuer_Ab  		[ block="VB2.1", pulse=400 ]
Thing pulse    Rollo_Terasse_Tuer_Zwischen 	[ block="VB2.2", pulse=400 ]
Thing memory   Rollo_Terasse_Tuer_Status 	[ block="VD120" ]

*.items
Rollershutter   EG_Terasse_Tuer_Rollade	  	"Terasse Tuer [%d %%]"     <rollershutter>    (EG_Wohnzimmer, gShutter)    ["Rollershutter"] {autoupdate="false"}
Switch  EG_Rollo_Terasse_Tuer_Auf      	"Terasse Tuer Auf" 	{ channel="plclogo:pulse:Logo1:Rollo_Terasse_Tuer_Auf:state" }
Switch  EG_Rollo_Terasse_Tuer_Ab 	    "Terasse Tuer Ab" 	{ channel="plclogo:pulse:Logo1:Rollo_Terasse_Tuer_Ab:state" }
Switch  EG_Rollo_Terasse_Tuer_Zwischen 	"Terasse Tuer Zwischen"	{ channel="plclogo:pulse:Logo1:Rollo_Terasse_Tuer_Zwischen:state" }
Number  EG_Rollo_Terasse_Tuer_Status	"Terasse Tuer Status"		{ channel="plclogo:memory:Logo1:Rollo_Terasse_Tuer_Status:value" }

*.rules
rule "Rollade UP"
when
    Item EG_Terasse_Tuer_Rollade received command UP
then
    EG_Rollo_Terasse_Tuer_Auf.sendCommand(ON)
end

rule "Rollade DOWN"
when
    Item EG_Terasse_Tuer_Rollade received command DOWN
then
    Rollo_Terasse_Tuer_Zwischen.sendCommand(ON)
end

//rule "Rollade Zwischen"
//when
//    Item EG_Terasse_Tuer_Rollade received command STOP
//then
//    EG_Rollo_Terasse_Tuer_Ab.sendCommand(ON)
//end

rule "Rollade Status"
when
    Item EG_Rollo_Terasse_Tuer_Status changed
then
    if (EG_Rollo_Terasse_Tuer_Status.state == 0) {
        EG_Terasse_Tuer_Rollade.postUpdate(100)
    }
        if (EG_Rollo_Terasse_Tuer_Status.state == 1) {
        EG_Terasse_Tuer_Rollade.postUpdate(50)
    }
        if (EG_Rollo_Terasse_Tuer_Status.state == 2) {
        EG_Terasse_Tuer_Rollade.postUpdate(0)
    }
end

*.Sitemap
Default item=EG_Terasse_Tuer_Rollade label="Terasse Tuer" icon="rollershutter"

if this dosent Work we can PM in German as long as the solution is posted here.

Thank you Bussdriver. It Works.

Does anyone know how to color the UP or DOWN buttons on a rolleshutter when an item is active? Or does that work with labelcolor? If yes how? it is enough for me if the label is green when the item is active.

Hallo,

how can I query the status of a flag? (Merker M8)
dreamar

Hello
First of all Read
PLCLogo Documentation

but here is a summary

//Things
Bridge plclogo:device:<DeviceId> [ address="<ip>", family="<0BA7/0BA8>", localTSAP="0x<number>", remoteTSAP="0x<number>", refresh=<number> ] 
{
Thing digital <ThingId> "Label" @ "Location" [ kind="M", force=<true/false> ]
}

//Items
Contact itemname   { channel="plclogo:digital:<DeviceId>:<ThingId>:M8" }

Greetings Markus

Here a tutorial for rollershutters: PLCLogo Solution: Logo Rollershutter Control

Hi !

I’m still trying during last weeks with my logos (i have 4 of them) to migrate this from fhem (where its still working with memory bits , fhem does trigger 1s via web command)
Its seems for me that openhab does not pulse… plc program is similar to solutions (use comfort swithc with 2 OR Inputs)
I can see the states of Q and so on… but proxy switch does not follow the Output and also output is not switched…
Also i get folowing log in events.log
2020-01-10 01:46:04.602 [vent.ItemStateChangedEvent] - FF_Buero_Light changed from ON to OFF
2020-01-10 01:46:04.612 [ome.event.ItemCommandEvent] - Item ‘TEST_BUERO’ received command ON
2020-01-10 01:46:04.614 [ome.event.ItemCommandEvent] - Item ‘TEST_BUERO’ received command OFF
2020-01-10 01:46:04.615 [nt.ItemStatePredictedEvent] - TEST_BUERO predicted to become NULL
2020-01-10 01:46:04.616 [nt.ItemStatePredictedEvent] - TEST_BUERO predicted to become NULL

The difference between on and off is 1 ms regardless how much i set as pulse… and also the NULL is a misery…

Ciao Gerd

Look at this Post or the other Posts in this Topic. They may help you.

Greetings Markus

Hi ! I read all these posts (also yours)
I can’t use M’s because nearly all are in use
I tried the other solutions with the vb 0.1 or similar and for me it seems that vb is not pulsed otherwise light shoudl go on and off

Ciao Gerd

Than you have to provide some configs of yours. (.items / .things / .rules / .sitemap)

Hi
OK
things

Bridge plclogo:device:logo_kg [ address=“192.168.63.101”, family=“0BA7”, localTSAP=“0x2000”, remoteTSAP=“0x2400”, refresh=200 ]
{
Thing digital KG_Outputs “Logo KG Ausgaenge” [ kind=“Q” ]
Thing pulse TEST_BUERO “Buero_Test” [ block=“VB100.4”, observe=“VB100.4”, pulse=“600”]
}

Item

Switch Licht_Buero “Buero Licht” { channel=“plclogo:digital:logo_kg:KG_Outputs:Q5” }
Switch TEST_OFFICE “Schalter Licht Essbereich” { channel=“plclogo:memory:logo_kg:TEST_BUERO:state” }
// virtual Switch
Switch FF_Buero_Light “Licht”

rule

rule “Switch Light Buero through Logo”
when
Item Licht_Buero changed or // 1. light changed external
Item FF_Buero_Light received command // 2. light changed internal
then
if(receivedCommand==ON || receivedCommand==OFF) { // ensure there was a received command, so second item triggered rule
if (Licht_Buero.state != receivedCommand) { // only if state changed
TEST_OFFICE.sendCommand(ON)
// TEST_OFFICE.sendCommand(OFF) // send an OFF, maybe not required
}
}
else { // no trigger from proxy switch, so state changed externally
if (Licht_Buero.state != FF_Buero_Light.state) { // if state changed really
FF_Buero_Light.postUpdate(Licht_Buero.state) // update the state without triggering the rule
}
}
end

sitemap

Group item=Buero label=“Buero” icon=“office”
{
Text item=Licht_Buero label=“Licht” icon=“light”
Default item=TEST_OFFICE label=“Debug NI1 (do not touch)”
Default item=FF_Buero_Light label=“EZ Licht (switch here)” icon=“light”
}

Hope this helps

Ciao Gerd

thing

Bridge plclogo:device:logo_kg [ address="192.168.63.101", family="0BA7", localTSAP="0x2000", remoteTSAP="0x2400", refresh=200 ]
{
Thing digital KG_Outputs  [ kind="Q" ]
Thing pulse Test_BUERO [ block="VB100.4", observe="VB100.4", pulse=600]
}

items

Switch Licht_Buero "Buero Licht" { channel="plclogo:digital:logo_kg:KG_Outputs:Q5" }
Switch Test_OFFICE "Schalter Licht Essbereich" { channel="plclogo:pulse:logo_kg:TEST_BUERO:state" }
// virtual Switch
Switch FF_Buero_Light "Licht" 

rules

rule "Switch Light Buero through Logo"
when
    Item Licht_Buero changed or // 1. light changed external
    Item FF_Buero_Light received command // 2. light changed internal
then
    if(receivedCommand==ON || receivedCommand==OFF) { // ensure there was a received command, so second item triggered rule
        if(Licht_Buero.state != receivedCommand) { // only if state changed
            Test_OFFICE.sendCommand(ON)
        }
    }
    else { // no trigger from proxy switch, so state changed externally
        if (Licht_Buero.state != FF_Buero_Light.state) { // if state changed really
            FF_Buero_Light.postUpdate(Licht_Buero.state) // update the state without triggering the rule
        }
    }
end

sitemap

sitemap default label="Home" {
Frame label="Light Switch" icon="office" {
        Switch item=FF_Buero_Light mappings=[OFF="AUS", ON="EIN"]
        Switch item=Licht_Buero label="Debug Test_BUERO (do not touch)"  // remove this line
   }
}

try this

greetings Markus

Great it works… and i saw my mistake…

Switch TEST_OFFICE “Schalter Licht Essbereich” { channel=“plclogo:memory:logo_kg:TEST_BUERO:state” }

instead of

Switch Test_OFFICE “Schalter Licht Essbereich” { channel=“plclogo:pulse:logo_kg:TEST_BUERO:state” }

Shame on me… but sometimes you can’t see the forest… :slight_smile:

Ciao Gerd

Hi !
After my first tries i can resume some technical issues (i earn my money with programming plcs)
This setup is running now for 2 days (1 dayparallel with fhem)
From technical side

  1. i don’t use pulses , because when i quickliy switch in webgui, sometimes the memory bit hangs and does not go back… so i have to switch it manually.
    i use send ON then sleep for 500ms and then send an OFF
  2. I send an OFF to the memory bits when system stops
  3. for me (and also from my experience in plc programming) it seems that LOGO Interface does not crash when 2 applications are connected (1 day i use parallel fhem) because i connect to 2 diffenet TSAPs (on is for fhem the other one for openhab = you need at least 1 server connection to connect to (e.g. my central LOGO has now 5 (1x fhem 1x openhab 3xother Logos)
  4. Regarding Point 2… my LOGOs are setup for a refresh of 300ms (i tried also with 2000ms) when you switch quickly in webif you might get some discconnect failures it doesnt really matter which refresh time you set

Also i loaded one Logo very often during test and i never had a crash…

HTH
Ciao Gerd

On the binding information there is a line : " Different families of LOGO! devices should work also, but was not tested now due to lack of hardware" Do someone have tested a Logo 0BA6 ?
Thanks in advance.

How you will connect to network ? 0BA6 does not have an ethernet port… starting with 0BA7 the heve Ethernet.

Ciao Gerd

Rollershutter Reloaded!
Here comes a rollershutter solution that leaves no wishes open (I hope).

Example / Functionality / Operation:

  • short Down-button: Q2 drives down for 5s / press again, drives down for the same time
  • long Down-button: Q2 drives down for 10s
  • short Up-button: Q1 drives up for 15s
  • short press any button any time stops motor
  • 500ms delay between changing motor direction
  • long press opposite button changes motor direction
  • continue or change direction at any time
  • emergency stop down (for door open sensor), normally LOW
  • updates Position (0% - 100%) correctly for up/down direction
  • Feature: slow update of Position (at 1s or more) good enough for polling Logo by openHAB


FInd the UDF for Logo8 and a Logo test-program here (rename to zip): Rollershutter_L8.zip.pdf (31.7 KB)

The test-program looks like this:

Do not forget to configure the VM for the ‘Position’:
Rollershutter_LogoSoft_VM-Config

Things

Bridge plclogo:device:Logo8 "Logo8 PLC" [ address="192.168.xxx.yyy", family="0BA8", localTSAP="0x2700", remoteTSAP="0x0300", refresh=1000 ]
{
  Thing digital Inputs  "Logo8 Inputs"   [ kind="I" ]
  Thing digital Outputs "Logo8 Outputs"  [ kind="Q" ]
  
  // Rollo1
  Thing memory VW0 "Logo8 VW0"                 [ block="VW0"]      // rollo position memory value-word
  Thing memory NI1_VB100_0 "Rollo1 ButtonUp"   [ block="VB100.0", force=false ]  // NI1 rollo control-bit memory button up
  Thing memory NI2_VB100_1 "Rollo1 ButtonDown" [ block="VB100.1", force=false ] // NI2 rollo control-bit memory button down
}

Items

// Rollo1
Number  Rollo1_Position "Rollo1 Position"   { channel="plclogo:memory:Logo8:VW0:value" }    // rollo's position (0% for completely open, 100% completely closed)
Switch  Rollo1_ButtonUp     { channel="plclogo:memory:Logo8:NI1_VB100_0:state" }        // for button up
Switch  Rollo1_ButtonDown   { channel="plclogo:memory:Logo8:NI2_VB100_1:state" }        // for button down
Switch  Rollo1_goingUp      "Q5"    { channel="plclogo:digital:Logo8:Outputs:Q5" }      // Logo relay for motor up
Switch  Rollo1_goingDown    "Q6"    { channel="plclogo:digital:Logo8:Outputs:Q6" }      // Logo relay for motor down
Rollershutter Rollo1 "Rollo Room1" <rollershutter>

Rules

// 3 imports otherwise error in the line with 'Direction == UP' (ref. openHAB log)
import org.eclipse.smarthome.core.types.Command
// import org.eclipse.smarthome.core.types.RefreshType
import org.eclipse.xtext.xbase.lib.Procedures

// you need this routine only once (for multiple rollerhuttrs)
val Procedures$Procedure4<Command, SwitchItem, SwitchItem, Command>
LogoRolloLogic = [ Command ReceivedCommand, SwitchItem Up, SwitchItem Down, Command Direction |
  switch(ReceivedCommand) {
    case UP: {
      Up.sendCommand(OnOffType.ON)
      Thread::sleep(100)              // create pulse
      Up.sendCommand(OnOffType.OFF)
      logInfo("LogoRolloLogic", "Direction: " + Direction + ". UP received.")
    }
    case DOWN: {
      Down.sendCommand(OnOffType.ON)
      Thread::sleep(100)              // create pulse
      Down.sendCommand(OnOffType.OFF) 
      logInfo("LogoRolloLogic", "Direction: " + Direction + ". DOWN received.")
    }
    case STOP: { // depending on driving up or down, push the corresponding button (may avoids immediate direction change, if pulse is too long)
      logInfo("LogoRolloLogic", "Direction: " + Direction + ". STOP received.")
      if (Direction == UP) {
        Up.sendCommand(OnOffType.ON)  // perform stop by sending Up-command if going up
        Thread::sleep(100)            // create pulse
        Up.sendCommand(OnOffType.OFF)
      } else if (Direction == DOWN) {
        Down.sendCommand(OnOffType.ON)  // perform stop by sending Down-command if going down
        Thread::sleep(100)            // create pulse
        Down.sendCommand(OnOffType.OFF)
      } else if (Direction != STOP) {   // do not send an up/down command if already stopped
        logDebug("LogoRolloLogic", "Direction " + Direction + " is not supported.")
      }
    }
  }
]

// repeat the following 2 rules for each additional rollerhutter
// Rollo1
rule "Rollo1PosChanged"
when
  Item Rollo1_Position changed
then
  var Number value = Rollo1_Position.state as Number
  Rollo1.postUpdate(value.intValue)  // return Position
end

rule "Rollo1Drive" // set direction and start driving up/down 
when
  Item Rollo1 received command
then
  var Command dir = STOP
  if (Rollo1_goingUp.state == OnOffType.ON) { dir = UP }
  else if (Rollo1_goingDown.state == OnOffType.ON) { dir = DOWN }
  LogoRolloLogic.apply(receivedCommand, Rollo1_ButtonUp, Rollo1_ButtonDown, dir)
end
// start_up rule will be added later

Sitemap

sitemap default label="Haus" {
    Frame label="Rollershutters" {
        // debug info
        Text item=Rollo1_ButtonUp   label="Rollo1_NI1_ButtonUp [%s]"    valuecolor=[OFF="red", ON="green"] icon=switch // this hides the switcher-control
        Text item=Rollo1_ButtonDown label="Rollo1_NI2_ButtonDown [%s]"  valuecolor=[OFF="red", ON="green"] icon=switch 
        Text item=Rollo1_goingUp    label="Rollo1_Q5_goingUp [%s]"      valuecolor=[OFF="red", ON="green"] icon=switch
        Text item=Rollo1_goingDown  label="Rollo1_Q6_goingDown [%s]"    valuecolor=[OFF="red", ON="green"] icon=switch
        Default item=Rollo1_Position
        // debug info
        Switch  item=Rollo1    
   }
}

Here is what you get (sitemap):

This is considered perfect now (does not use pulse-thing). No flaws, no issues.
Please check and feedback before I post it in ‘Solutions, Tutorials’.

Arnd

Hello All,

I new since begin this year to OpenHab an I wanted to level up my home automatisation with it.
My system is running on a Raspberry Pi 4 4Gb RAM with OpenHab 2.5.1.
OpenHab communicates with

  • 3x Logo7 via plclogo binding. (Pulse for input)
  • SMA Tripower via Modbus binding.
  • 2 chromecasts (1 audio, 1 normal)
  • Astro binding
  • Network binding
  • InFluxdb persistence to make graphs in Grafana.

Everything runs well, with in total 53 Items, 12 Items to Persistence, 4 simple rules.
CPU load is never more than 50% (normal 10%) Ram is average 35% loaded.

The 3 Logo7’s are controlling my home lightning and are running perfectly standalone (for the last 6 years), loaded with each a own programm which communicates with the others via network inputs, same as Openhab uses and also previously an HMI LOGO! app on my mobile phone.

BUT: only with openhab there are sometimes delays of 3 to 14s before an input is triggered.
I see in the log:
[ome.event.ItemCommandEvent] - Item ‘keuken_tafel’ received command ON
[vent.ItemStateChangedEvent] - keuken_tafel changed from OFF to ON

Normally there is about 200ms between these events, but that can run up to 13s.

I was looking at many other post but could not recognise the same issue/sollution.
Does anyone have an idea what could be the rootcause?

Thanks in advance,
P

An updated tutorial has arrived. Now finally LOGO! output-switching is possible using the Comfort-Switch block.
https://community.openhab.org/t/plclogo-solution-logo-output-switching/64264/10

Hello,

i want to connect the openhab to my Logo!8. The binding seems to be established because i get the system time of the Logo in the PaperUI

But the connection is not working with memory or pulse things. I just get the log:

2020-09-03 18:31:18.371 [INFO ] [ogo.internal.handler.PLCPulseHandler] - Wrong configurated LOGO! block VB1.0 found.
2020-09-03 18:31:18.372 [INFO ] [ogo.internal.handler.PLCPulseHandler] - Invalid channel plclogo:pulse:Logo4:VB1_0:state or client org.openhab.binding.plclogo.internal.PLCLogoClient@28d9576c found.

Here my config:

Any ideas what i’m doing wrong?
BR
Manuel