Integrate Siemens Logo (plclogo) in OpenHAB 2

Hi @jens

refresh and threshold are Integer parameter. Means it should be refresh=1000 instead of refresh=“1000”.
The same is for threshold parameter. Parameter force is boolean.

I’ve no idea why it worked before. I’ll update example in documentation section.

EDIT: If you configure via *.things file, please do not forget to restart a binding. I think, not sure about, that openHAB will not update configuration on update of *.things files.

Kind regards,

Alexander.

Again me,

I’ve updated https://github.com/falkena/binaries repository with new version of a binding. Changes:

  1. Remove a lot of duplicated code.
  2. Checking address range for VB/VD/VW blocks
  3. Write an error message to logger, if block configuration is wrong.

Feedback is welcome.

Kind regards,

Alexander

2 Likes

Hey @falkena,

all NPE errors seem to be gone, but I didn’t get any values from my logo. I’ve created some Things/Items with Eclipse Smarthome Designer, but I’m not getting any ItemStateChangedEvent in my events.log.

My logo.things:

Bridge plclogo:device:plc [ address="xxx", family="0BA7", localTSAP="0x2200", remoteTSAP="0x2200", refresh=100 ]
{
  Thing plclogo:digital:Q14 [ block="Q14" ]
  Thing plclogo:analog:Word [ block="VW60" ]
}

My logo.items:

Contact LichtAZ    {channel="plclogo:digital:Q14:state"}

Number Test {channel="plclogo:analog:Word"}

In the past I’ve tested the PLCLogo-Binding with openHAB 1.8 and alternatively the SimaticS7 Binding. I don’t remember where, but at one binding I couldn’t read outputs with Q14 and had to use the memory address VB943.5.
Is it possible to extend the ranges for VB in your binding according to http://www.frickelzeugs.de/logo-programmierung/vm-adressen-der-logo ?

Thank you and greetings,
BlackAlpha

HI @BlackAlpha,

try to change

to

Number Test {channel=“plclogo:analog:Word:value”}

The mapping is already done (LOGO_MEMORY_0BA7/LOGO_MEMORY_0BA8 variables):

If you are using Simatic S7 binding you need to take addresses, since it has no information about this.
For output Q14 is the base address = 942. Block number is 14.
Logo memory address for Q14 is calculated as: 942 + (14 - 1) / 8 = 943. Bit will be: (14 - 1) % 8 = 5.
The whole address for Q14 is than 943.5 in case of Logo7.

You will get a lot of information, if you set DEBUG Log-level. I should change some outputs to TRACE :slight_smile:
Kind regards,

Alexander

1 Like

Hi @falkena,

thanks for your reply, but just adding “value” didn’t work for me. :wink: I had to use localTSAP=“0x0100” and remoteTSAP=“0x0200”. Other TSAPs didn’t work and I don’t know why. In Logo ethernet connections everything is configured fine with remote and local 0x2200. :confused:

Now I’m able to read the word VW60. DWord seems to work fine, too! And after changing Q14 from contact to switch, it worked fine, too!

Thx for your work!!!

Maybe I’m to stupid, but now I’ve got another problem:
With only 1 Logo (bridge) everything is fine, but if I create another bridge only one is working. :confused:

There’s no difference if I create both bridges in one .things-file or if I create different files for each bridge. The PaperUI shows only 1 bridge, too.
The openhab.log shows no errors. :confused:

First file:

Bridge plclogo:device:plc "LogoUG" [ address="xxx", family="0BA7", localTSAP="0x0100", remoteTSAP="0x0200", refresh=100 ]
{
  Thing plclogo:analog:LogoUG_VD68 [ block="VD68" ]
}

Second file:

Bridge plclogo:device:plc "LogoOGLicht"  [ address="xxx", family="0BA7", localTSAP="0x0100", remoteTSAP="0x0200", refresh=100 ]
{
  
  Thing plclogo:digital:LogoOGLicht_Q14 [ block="Q14" ]
  Thing plclogo:analog:LogoOGLicht_VW60 [ block="VW60" ]
}

Greetz,
BlackAlpha

Hi @BlackAlpha,

cool :slight_smile: At least one LOGO! works :slight_smile:

According to http://snap7.sourceforge.net/logo.html local/remoteTSAP may be same.
According to https://support.industry.siemens.com/tf/WW/en/posts/is-tsap-hard-to-understand/26160?page=0&pageSize=10 they should be different, if more than one device is used.
PLCLogo binding is also some kind of PLC :wink:

Can you send me debug trace from openHAB and may be you LOGO! SoftComfort program via PM?
I’ll try to get a clue what going wrong. Sadly i can’t test this case now due to lack of second LOGO!

EDIT: Try to discover your LOGO’s via PaperUI. Discovering should find 4 devices in your case.
And there is no problem with already configured devices, as long auto-discovered bridges are in the In-Box.

Kind Regards,

Alexander

1 Like

Hi @BlackAlpha,

i think your Bridges need different ID’s try first file:

Bridge plclogo:device:plc1 "LogoUG" [ address="xxx", family="0BA7", localTSAP="0x0100", remoteTSAP="0x0200", refresh=100 ]
{
  Thing plclogo:analog:LogoUG_VD68 [ block="VD68" ]
}

second file:

Bridge plclogo:device:plc2 "LogoOGLicht"  [ address="xxx", family="0BA7", localTSAP="0x0100", remoteTSAP="0x0200", refresh=100 ]
{
  
  Thing plclogo:digital:LogoOGLicht_Q14 [ block="Q14" ]
  Thing plclogo:analog:LogoOGLicht_VW60 [ block="VW60" ]
}

at least i have it that way (but all in one file) …

greets
Jens

1 Like

Hi @falkena, Hi @jens,

after changing the bridges IDs and selectig different TSAPs for local and remote everything is working fine!

Thanks for your help and great work!!! :+1: :sunglasses:

Now one last question (different to explain for me):
I also use a AVM FritzBox DECT 200 to switch different devices on/off. Using the AVM binding it is possible to create only one switch item to read the status and switch the device on/off.

With openHAB 1.8 it wasn’t possible to define one switch item with different Logo memory addresses for input/output. You had to create one item which reads an output (eg. Q14) and another, 2nd, switch item which writes to the Logo to switch a lamp on/off (eg. to NI14). If you didn’t want to have 2 switch items in your visualisation, you had to create another, 3rd, switch and write a special rule/script to control this 3rd switch (write status of Q14) and read the on/off commands from it to write it to switch 2 (NI14). This procedure is complicated, complex and made different problems for just switching a light or device on/off.

Is there a smarter way in openHAB2?

Or is it possible to code a special thing to the binding, which accepts different blocks for input/output and sends a short pulse to the output adresses if the switch receives a command?

Maybe like this (dreaming of it :wink: ):

Thing plclogo:virtual:VirtualSwitch01 [ output="Q14", on="NI01", off="NI02", pulse=100 ]

output = The Logo output to read from
on = The Logo network input to send a pulse to to switch the output on
off = The Logo network input to send a pulse to to switch the output off
pulse = Pulse length in miliseconds

If you use a Stromstoßrelais (sorry, I don’t know the english word for it :joy: , dict.cc said it is called “surge relay” :grin:) which has different inputs for trigger, set and reset, you could use the trigger to switch the relay from a Logo input and set/reset in combination with network inputs to switch the relay out of openHAB.

Greets,
Carsten

Hi @BlackAlpha,

that is mostly what i have too, starting from logocontrol(frikelzeugs.de)…

if you change your logo program for a lamp e.g. to:

you only need one network input, but you still need 3 things and items and a rule in openhab. I made some spreadsheet that generates the things, items and rules i need for that. I even did that for the shutter programs of frickelzeugs.de - so it’s only some copy and paste - the link to it is somewhere on top.

Maybe we could define a logo program that correlates with a thing like a vLightSwitch with your thing definition. The same for a shutter like vShutterControl with the frickelzeugs programm - it would need three inputs (up/zpos/down) and read the state of a shutter (a VW).

Having a pulse for a network input would be great, because doing it with the rule is ok, but sometimes “hakelig” (en: juddery???).

So you have pushbutton’s on your wall’s too?

Greets,
Jens

Hi @jens,

That’s the way I used with openHAB1. If there is a way to realize this “virtual item” in openHAB2 with one only network input, it will be better of course.

That’s what I’ve ment with “This procedure is complicated, complex and made different problems…” :wink:

Yes. I’m using normal pushbuttons for lights and shutters.

The more I think about it, there would be 3 “virtual items” usefull:

  1. virtual switch like explained above
  2. virtual shutter control (with and without zpos)
  3. virtual open/close item (I don’t know how to call it) for opening doors, gates or something else

@falkena: How could I send you a beer? :wink:

Greets,
Carsten

Hi @BlackAlpha, @jens

Cool, that the things working now :slight_smile:
I’ll update documentation how to configurate multiple LOGO!'s: Have not realized the stuff with different thing id’s yesterday. It was too late :slight_smile:

Well, it should be possible to do. On my opinion, it should be better to declare it as

Thing plclogo:button:VirtualSwitch01 [ output=“Q14”, input=“VB0.0”, kind=“closer/opener/frequency”, pulse=100 ]

This will emulate a kind of push button. Something similar to switch simulation in LOGO! Soft Comfort.
It should be not a huge problem to implement this.

About rollershutter: What is zpos? Have never seen Frickelzeugs vShutterControl. May be it’s time to take a look :slight_smile: Can you post thing definition you are thinking about? May be I’ll get more clue, what you do you mean.

About “Open/Close” - Item: I think, it’s a simply rollershutter?

@BlackAlpha What TSAP’s are different? Local, remote or both for each LOGO!?

No problem. I’m from south Germany :wink::yum:

Kind regards,

Alexander

PS:
@BlackAlpha, @jens: I’ll wait until weekend with PR. And if you find nothing, I would make a PR. Then we can take a look to implement at least “button”-Thing :slight_smile:

Hi @falkena,

This sounds nice. What do you mean with kind=“frequency”?

Some users are measuring the time to calculate the actual position of the shutter. It’s not very precise but better than nothing… :wink: A possible thing definition:

Thing plclogo:button:VirtualShutter01 [up="VB0.0", down="VB0.1", position="VW50"]

The more I think about it… you’re right! :slight_smile:

The TSAPs for local and remote shouldn’t be the same with your binding. I’ve changed localTSAP to 0x1200 and remoteTSAP to 0x2200 for every plc and everything works fine now.

I’m in south germany for summer holidays… :wink:

@falkena: Yesterday I got some exceptions after changing the Logo program with Siemens Logo Soft while openHAB was running and one plc-process crashed. I’m watching this to send you more details if possible.

Greetings,
Carsten

Hi @falkena,

Thanks a lot for your effort on this addon.
I’d like to join the testing team :slight_smile:
I currently have one LOGO! 8.FS4 in my “lab”.

I installed latest binary from your github and it detected my LOGO correctly.
I created the bridge and some Q things using paper UI and all show up as Online.
The problem started when I tried to link items with channels.
Looks like state is not detected as correct channelType.
Not sure if this is a configuration problem or addon/paper UI bug.
Have you seen anything like this?

Regards,
Jacek

Hi @falkena,

zpos is an additional position you can trigger(actually two positions). “vShutterControl” was just a name for the virtual thing, that came to my mind.

The frickelzeugs.de shutter program has not only up and down, but a position in the middle that you can trigger. You can set times for four functions:

up-time: when you trigger up - the time the program holds the up output active - e.g.: 19sec
down-time: when you trigger down - the time the program holds the down output active - e.g.: 15sec

zpos-time when state is up: when you trigger zpos - the time the program holds the down output active - e.g.: 9sec
zpos-time when state is down: when you trigger zpos - the time the program holds the up output active - e.g: 3sec

I have my wall pushbutton with an up and down button and a program(from frickelzeugs.de too), that can recognise if i just push or hold for a little longer. So let’s say the shutter is up - if i just push down short, the shutter goes down for 15sec(that is totally closed), but if i hold down (for about a second(you can configure that too)) it goes 9 sec down(that is down with the little spaces open).

The thing wouldn’t have to hold up or down - as you can directly trigger zpos, but i don’t want to have another button on my wall for that.

As the program knows the times the shutter needs to go down and up, it counts them and therefor knows the state of the shutter. You can read its state and visualise it in openhab. I have little windows with either open, middle or down state. Therefor i currently have this thing:

Thing plclogo:analog:Logo_1_VW_452 [ block="VW452", threshold="1" ]

that is 0, 1 or 2 then. I transfer this with my shutter rule to state 100, 50 and 0 of my virtual shutter item (i called them Proxy_…).

That would make, close to what @BlackAlpha said:

Thing plclogo:button:VirtualShutter01 [up="VB0.0", zpos="VB0.1", down="VB0.2", position="VW50"]

and i don’t know if possible the position directly transferred from 0,1,2 to 100,50,0…
How would the corresponding item look like? Can we do this with the Rollershutter item?

Greets
Jens

Hi @all,

@jens

Sorry, I misunderstood zPos. I’ve tested Frickelzeugs Logocontrol just for one day… :grin:

@falkena:

I’ve finalized my (complex) rollershutter UDF in the Logo Software today to get a “precise” position where the shutters stopped. Because of lack mathematical functions of the Logo software it isn’t possible to get this position as a percent value (I’ve used a normal counter in the Logo program, but i found no way to re-calculate it to a percent value). So an additional “maxPosition”-value would be nice to convert the position to the needed percent value.

My example (zPos renamed to partial):

Thing plclogo:button:VirtualShutter01 [up="VB0.0",down="VB0.1",partial="VB0.2",position="VW50",maxPosition="123"]

I think partial, position and maxPosition should be optional.

@skazi

I’ve tried it and can confirm this. I use Eclipse SmartHome Designer to declare Things, Items etc “by hand”. Using this way, everything works fine.

Greetings,
Carsten

Hi @BlackAlpha,

it’s not in Logocontrol, there is an UDF on that site, that has all this.

Would you share your program? Maybe i can bring in some good ideas…or work together.

Greets
Jens

p.s. @skazi: i’m using SmartHome Designer too, way to much clicking for all those things and items…

I’ll contact you via PN… :slight_smile:

Hi everybody,

@skazi: Thanks. I’ll take a look what’s wrong here.

@jens, @BlackAlpha: Ok. We will make two things:

Thing plclogo:button:btn [ input=“VB0.0”, output=“Q1/NQ1/M1/VB0.1”, kind=“closer/opener/frequency”, pulse=100 ]

Frequency is used with “Threshold-Switch”-Block. I think, we can omit this. “Input” value is requered field. Other are optional. Thing will provide 2 channels: “input” for “Contact” items inputs and “output” for “Switch” items. Attention: Here VBx.x blocks will take “Contact”-items due to thing logic Other fields are simply parameter.

Thing plclogo:shutter:sht [up=“VB0.0”, down=“VB0.1”, position=“VW50”, zpos=???, min=0, max=100]

Thing would provide at least one channel “shutter” for “RollerShutter” and/or “Dimmer” tems. Have no idea now about zpos: must take a look into UDF. Additionally, i’m not sure how to react to StopMove rollershutter, IncreaseDecrease dimmer and Percent rollershutter/dimmer commands. Now the task is: “Think really hard”… Ideas are always welcome :slight_smile:

Miss i something?

Kind regards,

Alexander.

Yes, maxPosition=“123”… :wink:

@BlackAlpha: No way… RollerShutter/Dimmer takes Percent as command… Means you should post it in a properly way from LOGO!. Take a look to “Math functions” block, is available since 0BA6.

EDIT: Sorry, was too fast. I can scale it myself… So, we need: min/max as parameter also.