Integrate Siemens Logo (plclogo) in OpenHAB 2

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

Have you tried with default localTSAP="0x0300" and remoteTSAP="0x0200" ?

It shall be

family="0BA8" instead of family="<0BA8>"

@skazi @falkena
Thanks for reply. It was just the typo and with the correct family it works family="0BA8" :smiley:

Hi everybody,

I`m trying to get openHAB connected with my Siemens Logo (0BA8) in order to use switches for turning Lights ON/OFF und to user rollershutters.

Therefore my PLC Logo8_3 is ONLINE.
As well I have configured a Thing called Digital Input/Output.

But I don`t really know what I did wrong-nothing works (just openHAB, no logocontrol running).

Attached you can find my configuration.
Maybe someone who also went thru this can help me.

First it would be great to get switches running (in Logo Soft Comfort: NI2 / VB222.2 --> Q1).

// logo.things

//IR-Heizung Bad
Bridge Logo8_3-plclogo:device:192_168_178_14 [ address=“192.168.178.14”, family=“0BA8”, localTSAP=“0x2000”, remoteTSAP=“0x1000”, refresh=333 ]
{
Thing digital Inputs [ kind=“I” ]
Thing digital Outputs [ kind=“Q” ]
Thing memory VB222 [ block=“VB222.2”, threshold=1, force=true ]
}

// logo.items

// IR-Heizung Bad
Switch IR_Heizung_Bad_Q1 “Q1” {channel=“plclogo:digital:a39de6de:Outputs:Q1”}
Contact IR_Heizung_Bad_I1 { channel=“plclogo:digital:a39de6de:Inputs:I1” }
Switch IR_Heizung_Bad_VB222_2 “VB222.2” {channel=“plclogo:memory:a39de6de:VB222:state”}

// logo.rules

// IR-Heizung Bad
rule “update VB222.2”
when Item IR_Heizung_Bad_Q1 received update
then
if (IR_Heizung_Bad_Q1.state==ON) {
IR_Heizung_Bad_VB222_2.sendCommand(ON)
} else {
IR_Heizung_Bad_VB222_2.sendCommand(OFF)
}
end

// haus_sitemap

Group item=OG_Bathroom label=“Badezimmer” icon=“bath” {
Frame label=“Light Switch” icon=“attic” {
Switch item=IR_Heizung_Bad label=“Infrarotheizung” icon=“radiator”
}
}

Thanks a lot in advance for your help.
Have a nice day.

First try with this:

  • Bridge name should start with plclogo
  • Channels in items have to start with bridge name
// logo.things

//IR-Heizung Bad
Bridge plclogo:device:192_168_178_14 [ address=“192.168.178.14”, family=“0BA8”, localTSAP=“0x2000”, remoteTSAP=“0x1000”, refresh=333 ]
{
Thing digital Inputs [ kind=“I” ]
Thing digital Outputs [ kind=“Q” ]
Thing memory VB222 [ block=“VB222.2”, threshold=1, force=true ]
}

// logo.items

// IR-Heizung Bad
Switch IR_Heizung_Bad_Q1 “Q1” {channel=“plclogo:digital:192_168_178_14:Outputs:Q1”}
Contact IR_Heizung_Bad_I1 { channel=“plclogo:digital:192_168_178_14:Inputs:I1” }
Switch IR_Heizung_Bad_VB222_2 “VB222.2” {channel=“plclogo:memory:192_168_178_14:VB222:state”}

// logo.rules

// IR-Heizung Bad
rule “update VB222.2”
when Item IR_Heizung_Bad_Q1 received update
then
if (IR_Heizung_Bad_Q1.state==ON) {
IR_Heizung_Bad_VB222_2.sendCommand(ON)
} else {
IR_Heizung_Bad_VB222_2.sendCommand(OFF)
}
end

// haus_sitemap

Group item=OG_Bathroom label=“Badezimmer” icon=“bath” {
Frame label=“Light Switch” icon=“attic” {
Switch item=IR_Heizung_Bad label=“Infrarotheizung” icon=“radiator”
}
}
1 Like

Thanks a lot skazi for your help.

I did exactly what you recommended.
Unfortunately no changes so far.

One further question to you:

Is ist enough to have the PLC “Logo8_3” running (ONLINE), or do I have to do something else in the Paper UI, like configuring further Things or Channels?

Is it needed to habe a Thing running for digital blocks?

Thank you very much in advance.

I’m doing everything using config files so I’m pretty sure there’s nothing you need to do in PaperUI explicitly.

Maybe describe what you’re trying to do exactly. What is your wiring and what do you want the items/rules to do.

Thank you skazi.

Unfortunately I cannot send you the messages I want to due that I`m a new user.
I also cannot provide you new Pictures due to that.

Atached you can see, what I want to have in openHab.
Means I want to have a switch which shows me if this program is in Hand/Auto-Mode, with the possibility to turn it on in Hand-Mode.
I also want to have a Indicator, if it is turned on or not.
You can also get me via Email, if you want to.

Thank you.

Since you’re using Pulse Relays pulse things look like a best match.
You don’t really need NQ if it just maps to Q. You can read Q directly (see below).
Try like that (note that I have replaced quotes with plain ones):

// logo.things
//IR-Heizung Bad
Bridge plclogo:device:192_168_178_14 [ address="192.168.178.14", family="0BA8", localTSAP="0x2000", remoteTSAP="0x1000", refresh=333 ]
{
Thing digital Inputs [ kind="I" ]
Thing digital Outputs [ kind="Q" ]

Thing pulse NI1 [ block="VB222.0", pulse=200 ]
Thing pulse NI2 [ block="VB222.2", pulse=200 ]
}

// logo.items
// IR-Heizung Bad
Group OG_Bathroom
Switch IR_Heizung_Bad_Ein "Infrarot Heizung" (OG_Bathroom) {channel="plclogo:digital:192_168_178_14:Outputs:Q1"}
Switch IR_Heizung_Bad_Hand_Ein_NI "Infrarot Heizung NI" (OG_Bathroom) {channel="plclogo:pulse:192_168_178_14:NI2:state"}
Switch IR_Heizung_Bad_Hand_Auto_NI "Infrarot Heizung Hand/Auto NI" (OG_Bathroom) {channel="plclogo:pulse:192_168_178_14:NI1:state"}

// logo.rules
// IR-Heizung Bad
rule "IR_Heizung_Bad_Ein Forward to NI"
when
    Item IR_Heizung_Bad_Ein received command
then
    sendCommand(IR_Heizung_Bad_Hand_Ein_NI, ON) // short pulse
end

// haus.sitemap
sitemap haus label="Haus" {
  Group item=OG_Bathroom
}

Thank you once more, skazi.

I guess the sitemap doesn`t work for me.

I did it like this:

  Group item=OG_Bathroom label="Badezimmer" icon="bath" {
        Frame label="Rollo" {
        Default item=Rollo10 label="Fenster" labelcolor=[IT_Rollo10_Runter==ON="red",IT_Rollo10_Hoch==ON="red" ]
        }
        Frame label=“Light Switch” icon=“attic” {
        Switch item=IR_Heizung_Bad label=“Infrarotheizung” icon=“radiator”
        }
        }

Unfortunately my sitemap ist not accessable anymore, if I use these parameters.
What am I doing wrong?

Thank you.

I can see different types of quotemarks in your sitemap, not good.