Integrate Siemens Logo (plclogo) in OpenHAB 2

Thanks @falkena for the great binding.
I am now working with the merged version from the openHAB 2.4 on RaspberryPI.
There were many contributions for practical solutions above - thanks as well. This thread becomes quite overloaded, imho. I think we should create a new forum thread to collect solutions that are complete and 100% work (fool-proof).

One post in that thread contains one solution? Or like the “Design Pattern” (one topic per solution)? Tagged with [Tutorials & Examples] [Solutions] [Bindings]

This should be editable (for revision) by all, if possible? Alternatively feedback from replies is incorporated into the 1st post (by the author of thread).
Should contain some structure, e.g. Problem Statement, Concept, Example, a screenshot of what you get (sitemap screenshot), openHAB version, zip-file with all openhab-config files and maybe Logo-config (Logo soft comfort file or screenshot of the Diagram-Editor. Drawback: This forum does not permit zip-file uploads, therefore all config must be placed as code fences in the post.

What do you think?

I wish we could get properly consolidated examples for:

  • rolloshutters
  • lights (switch + status indicator)
  • timer configuration (setting logo clock parameters…more in a later post)

Here an example as template.

Thread-name PLCLogo Solution: Logo Input Monitoring

Problem Statement

How to obtain status of Logo-inputs for window/door alarm contacts?

Concept

Reading inputs of a Logo via openHAB PLCLogo binding and visualize their status (read-only) in a sitemap. Magnetic alarm contacts provide the open/closed status of a window or door. A closed alarm contact shall represent a closed window/door. Connect each alarm contact to a dedicated Logo-input. A sophisticated Logo configuration is not required because Logo-inputs are directly read by the PLCLogo binding.

This thread is a wiki article and can be improved by everyone. Please do!

Solution

Here is a screenshot of what the result look like.


(Screenshot contains modified icons, not included.)

LOGO! Configuration (LOGO! SoftComfort Diagram Editor)
OpenHAB_LogoPLC_alarmcontacts_Logo-config

Things (logo7.things)
In this example, the IP address 192.168.xxx.yyy represents the Logo device’s address and must be adapted.

Bridge plclogo:device:Logo7 "Logo7 PLC" [ address="192.168.xxx.yyy", family="0BA7", localTSAP="0x0200", remoteTSAP="0x0200", refresh=1000 ]
{
  Thing digital  Inputs "Logo7 Inputs"    [ kind="I" ]
  Thing digital  Outputs "Logo7 Outputs"  [ kind="Q" ]
}

Items (logo7.items)

Contact Logo7_I1    "Fenster WC [MAP(contact_door_de.map):%s]"      <window> { channel="plclogo:digital:Logo7:Inputs:I1" }
Contact Logo7_I2    "Haustür [MAP(contact_door_de.map):%s]"         <frontdoor>   { channel="plclogo:digital:Logo7:Inputs:I2" }
Contact Logo7_I3    "Fenster Küche [MAP(contact_door_de.map):%s]"   <window> { channel="plclogo:digital:Logo7:Inputs:I3" } 
Contact Logo7_I4    "Fenster Essen [MAP(contact_door_de.map):%s]"   <door> { channel="plclogo:digital:Logo7:Inputs:I4" }
Contact Logo7_I5    "Fenster Wohnen (links) [MAP(contact_door_de.map):%s]"  <door> { channel="plclogo:digital:Logo7:Inputs:I5" }
Contact Logo7_I6    "Fenster Wohnen (rechts) [MAP(contact_door_de.map):%s]" <door> { channel="plclogo:digital:Logo7:Inputs:I6" }

Transformation (contact_door_de.map)
Make sure you have the Map Transformation service installed in Add-ons / Transformations.

CLOSED=ZU
OPEN=OFFEN
NULL=undefiniert
-=Strich

Sitemap (default.sitemap)

sitemap default label="Haus" {
Frame label="Alarmkontakte" icon="groundfloor" {  // icon does not work
        Default item=Logo7_I1   valuecolor=[CLOSED="green", OPEN="red"]
        Default item=Logo7_I2   valuecolor=[CLOSED="green", OPEN="red"]
        Default item=Logo7_I3   valuecolor=[CLOSED="green", OPEN="red"]
        Default item=Logo7_I4   valuecolor=[CLOSED="green", OPEN="red"]
        Default item=Logo7_I5   valuecolor=[CLOSED="green", OPEN="red"] 
        Default item=Logo7_I6   valuecolor=[CLOSED="green", OPEN="red"]
    }
 }

Revision History

  • January 2019: original post for openHAB version 2.4 with Logo 0BA7

Troubleshooting

  • nothing so far

Next Ideas

  • none so far

Arnd

1 Like

I can turn the post into a wiki if desired. Just tag me with @ and I’ll do it when you are ready.

Or open a github repo to put it into.

Also look at the InfluxDB+Grafana Tutorial and MQTT 101 tutorial for some good examples of how to structure a tutorial like this.

Hi @Euphi,

thanks :slight_smile: I’ll try to answer your questions:

Well, the procedure is well described in manual to LogoSoftComfort: simply search for “network project” and/or “ethernet connections”. An Pull-Request with updated documentation is also welcome.

I’ve added some lines to documentation

Well, let’s take a look into manual to LogoSoftComfort again: Logo can address 851 bytes (range 0 - 850). Each byte contains 8 bits. Means: we will have a thing with 6808 channels. It’s really huge thing:-)

See here for explanation

Again, manual to LogoSoftComfort will help us. Siemens online documentation is helpful too. Just for info: Siemens has increased number of digital outputs to 20 (yeah, it’s really huge) in Logo!8 compared with 16 in Logo!7.

Kind regards,

Alexander

Problem for me was that a network project still requires that the actual connection is setup as normal ethernet connection. It is not sufficient to create the connection in the “Network Project” only. While this is clearly an issue of the LogoSoft Comfort documentation, the process to set and see the TSAP configuration could be explained better in the binding documentation. When I find some time, I’ll create a PR.

Where? Is it already available?

Yes, but if you want to make use of them, you will have 851 Things?!

Yeah, but there are 64 Network Inputs and 64 Network Outputs? But also for an NQ-Thing “only” 20 Channels are created. Is it possible to create all 64? (Without need to configure them manually)?

Explanations like these are why a think that Contact is wrong. A network input of the Logo can be the output of Openhab, so it should be possible to configure it as Switch.

No, in worst case i’ll have 6808 things :slight_smile: In base case no one. Your suggestion creates always 6808 channels.

Sorry, i can’t reproduce the error:
grafik

If you find a way how to modify network inputs directly without mapping to memory, tell me, please. I’m very interested on the solution.

Kind regards,

Alexander

@rlkoshak
Thanks for your advice.
I have created a new thread for the solution above.

Please make it a wiki article.

done. it should be a wiki now. thanks for posting!

@falkena
I think we need a pulse-thing, with opener/closer behaviour, i.e. that assures a retun to 0.
Sometimes I have a sticky NI (network input) that behaves somehow inverted.

I am still trying to build the perfect light-switch. Thanks @mcullmann (post 180 above).
Let me summarize:
example_light_switch_logo
Comfort-Switch B003 switches Q7 permanently, if pulse us longer than 500ms. A short pulse switches-on Q7 only for 20s. B033 to assure that pulse from NI1 is longer than 500m (e.g. 600ms)

Sitemap

sitemap default label="Home" {
Frame label="Light Switch" icon="attic" {
        Default item=FF_Dining_Light label="Light (switch here)"
        Text  item=Logo7_Q7 label="Debug Q7"
        Default item=Logo7_NI1 label="Debug NI1 (do not touch)"
   }
}

Things

Bridge plclogo:device:Logo7 "Logo7 PLC" [ address="192.168.xxx.yyy", family="0BA7", localTSAP="0x0200", remoteTSAP="0x0200", refresh=1000 ]
{
  Thing digital Inputs "Logo7 Inputs"    [ kind="I" ]
  Thing digital Outputs "Logo7 Outputs"  [ kind="Q" ]
  Thing pulse     VB100_0  "Logo7 NI1"  [ block="VB100.0", observe="VB100.0", pulse=200  ]
}

Items

Switch  Logo7_Q7    "Licht Essen [%s]" <light>         { channel="plclogo:digital:Logo7:Outputs:Q7" }
Switch  Logo7_NI1   "NI1"    { channel="plclogo:pulse:Logo7:VB100_0:state" }
// virtual Switch
Switch          FF_Dining_Light            "Licht"               <light>            (FF_Dining, gLight)

Rules

rule "Switch Light through Logo"
when
    Item Logo7_Q7 changed or                         // 1. light changed external
    Item FF_Dining_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 (Logo7_Q7.state != receivedCommand) {      // only if state changed
            Logo7_NI1.sendCommand(ON)                 // send an ON
            Logo7_NI1.sendCommand(OFF)                // send an OFF ?? Is that really necessary ??
        }
    }
    else {                                             // no trigger from proxy switch, so state changed externally
        if (Logo7_Q7.state != FF_Dining_Light.state) { // if state changed really
            FF_Dining_Light.postUpdate(Logo7_Q7.state) // update the state without triggering the rule
        }
	}
end

This seems a bit shaky when toggling Light switch, esp. when toggling fast (status hicks up). Also it does not read the initial state (if logo-light was already on, and then starting up openHAB).

Can we find a simpler solution for light-switching, e.g. without rules?

For switching my lights I use wall pushbuttons.
I can’t use the pulse thing because then I don’t have the status of the output in logo.
To have the status on openhab correct I did it this way and it works great.
29

My wall pushbuttons pulse the pulse relay, the openhab-switch sets/resets the output.

Logo.things:

Bridge plclogo:device:Logo1 [ address="192.168.0.90", family="0BA8", localTSAP="0x3000", remoteTSAP="0x2000", refresh=50 ]
{
  Thing digital  Inputs  [ kind="I" ]
  Thing digital  Outputs [ kind="Q" ]
  Thing memory   VB0 [ block="VB0.0", threshold=1, force=true ] //Geen pulse item gebruiken!!

}

Logo.items

//Items
Switch Logo1_Q1 "Q1" {channel="plclogo:digital:Logo1:Outputs:Q1"}
Contact Logo1_I1    { channel="plclogo:digital:Logo1:Inputs:I1" }//Niet nodig voor lichtsturing, enkel status Q nodig
Switch Logo1_VB0_0 "VB0.0" {channel="plclogo:memory:Logo1:VB0:state"}

Logo.rules:
Update state openhab switch according to output state.
Maybe a postupdate would be better than a send command, but it works.
It sends another set or reset to the logo, but it doesn’t do anything because the output is already set or reset.

//rules
rule "update VB0.0"
when Item Logo1_Q1 received update
then
  if (Logo1_Q1.state==ON) {
    Logo1_VB0_0.sendCommand(ON)
  } else {
    Logo1_VB0_0.sendCommand(OFF)
  }
end

Home.sitemap

//sitemap
sitemap Home label="Home" {
    Switch item=Logo1_VB0_0
}

There is still a rule necessary, but its a small one.:wink:

Kind regards,
Brecht.

@Brecht take a look at my example here: Integrate Siemens Logo (plclogo) in OpenHAB 2

// things
Thing  digital Outputs [ kind="Q" ]
Thing  pulse   VB0_1   [ block="VB0.1", pulse=100 ]
// items
Switch  Relay1    "Relay#1"   (LOGO1)  { channel="plclogo:digital:PLC01:Outputs:Q2" }
Switch  PLC01_NI1 "PLC01_NI1" (LOGO1)  { channel="plclogo:pulse:PLC01:VB0_1:state" }
// rules
rule "forward Relay1 command to logo NI1"
when
    Item Relay1 received command
then
    sendCommand(PLC01_NI1, ON) // short pulse
end

This seems to work fine with following circuit:

Zrzut%20ekranu%20z%202019-01-13%2018-38-44

I then add Q2 to the habpanel. Commands sent to this item are not handled directly but “forwarded” to the NI item by the rule.

@skazi

Thank you. Your solution is even better, less code & less blocks.
I’ll implement it your way.

Do you perhaps have a solution for roller shutters too?

Kind regards.
Brecht.

Hi @Brecht,

I’m glad that you like the light solution.
I have roller shutters implemented in LOGO but I haven’t connected them to openhab just yet.

BR,
Jacek

Thanks @Brecht, @skazi, @mcullmann,
I have created a new turorial/solution topic for this - still WiP

@rlkoshak please make that a wiki.

Next should be rolloshutters.

Thren I have a challenge for Logo clocks. How to write times? Reading times works already nicely with plclogo-binding.
Android HMILogo app does that with a perfect widget (3 tabs for 3 clocks, weekday-selector, on/off-time reader + setting)
HMILogo_clock_widget

Hi @skazi, I just started to work with Openhab, and I’m looking to control my PLC Logo 8 with OPENHAB
could You please help me how to proceed??
best regards
dave

Hi @Dave_gagliostro,

Assuming you have your LOGO connected and working from LOGOComfort, I think the best place to start with OpenHAB integration is this: https://github.com/openhab/openhab2-addons/blob/master/addons/binding/org.openhab.binding.plclogo/README.md

Reading this thread from the beginning might also give you some nice troubleshooting hints.

BR,
Jacek

Hi @falkena,

now the pulse thing is working for me, thanks!

But now I have another problem. I’m not able to send a Value from a number item to the logo. I tried some ways. I tried to bind the Number channel to a memory thing. I tried to bind the number channel to analog network thing. But the value does not arrive the logo VM.
Reading analog value from the logo works fine.
And it works with Switch items and writing only bits to the logo VM. Both ways: digital thing or memory thing.

In my case I have a Networt Analog Input NAI1 which maps to VW140.

Here the example with the analog thing:
thing-file:

Thing analog Analog_Thing_1 [kind="NAI"]

items-file

Number Test_Number {channel="plclogo:analog:Logo1:Analog_Thing_1:NAI1"}

rule

Test_Number.sendCommand(50)

Where is the mistake? Can you help me how to proceed?

BR
nickd

hi @nickd

You cannot write directly in analog inputs or Network (analog) inputs.
You have to write the number value into V-memory and then in logo connect NAI1 to V-word.

See table here: you have to write the number value in Word VW100 or Double Word VD100

Logo
image

Kind regards.
Brecht.

Hi @Brecht

thanks for your fast reply!
I tried it this way, too but it doesn’t work.

Here my code:

//thing
Thing memory MEM_VW140 [ block="VW140"]

//item
Number Test_Number {channel="plclogo:memory:Logo1:MEM_VW140:value"} 

//rule
Test_Number.sendCommand(50)

Logo
grafik

With Bits (VB) and digital thing it works.

Another hint for me?

Regards,
nickd

Ok, now it seems to work.
I checked all created things in PaperUI and I saw that the memory thing was not intialized. Then I changed the name of the memory Thing…after that I saw in the log that it was initialized.
After renaming it again to the old name I got an error message like this

2019-01-16 19:34:20.971 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while disposing handler of thing 'plclogo:memory:Logo1:Mem_GZ_Jal_desV': Provider for thing plclogo:memory:Logo1:Mem_GZ_Jal_desV cannot be determined because it is not known to the registry

After restart of openHab it is working…don’t ask me for the reason of this error…no idea… I’m happy that it’s working now…:slight_smile:

BR
nickd