Integration of ladder programming or functional plan similar Step7

Hi developers,

you are doing a really great job. Thank you for this awesome project. I love it.
But I would like to request the above mentioned feature because in my eyes it is easier to manage than nodeRed for newbies. I’m a S7-PLC programmer and i know ST and SCL (Siemens) and so on as well.
DIN EN 61131-3
At some point of size of an automation node Red will be confusing.

What do you think? Will it be possible? Have I aroused your interest? :slight_smile:

Personally I never liked PLC programming. Ladder logic is strange.

If you don’t like Node Red (I’m not a fan either), try the GUI automation editor or YAML. There’s little that NR can do that the editor and/or YAML can’t.

1 Like

Node-Red is an open-source software project that is independent of the Home Assistant project.

Home Assistant can communicate with Node-Red via its API and custom nodes. In other words, a software developer created an interface between the two products.

If you know of an existing open-source “ladder programming” product that has an API, then perhaps there’s a chance a volunteer software developer can create an interface to connect Home Assistant to it.

If there’s no such open-source product, then the odds of someone creating it specifically for Home Assistant are low.

I don’t say that to discourage you, only to guide your expectations.

1 Like

I have never been involved in PLC programming either, but what I understand from it is that PLC programming is based on a different paradigm. Correct my if I’m wrong while trying to explain what I thing is the difference.

Usually PLC logic is based on a continuous loop evaluating states and executing rules in a pure deterministic way.

Home Assistant is event driven. It only reacts when some specific thing happens. It requires different thinking, and also results in differences in behavior. As a result is is less deterministic (I know that sounds strange) but it has it advantages:

PLC’s are great where the desired new state is always perfectly defined, based on the current state it knows exactly what to do and it does. A specific state will result in specific behavior almost immediately (the time it takes to iterate a full loop). For industry I’d say that is a must. Safety and proper functioning of devices depend on it.

My home however is often not that deterministic. There are many rules, but also many instances where a user would want to intervene (seemingly in violation of those rules). If only because HA can never have all information needed, and rules to govern the whole house are never complete.

Event driven systems are better suited for home automation i.m.h.o. They react to changes (events). PLC’s respond to something being a certain way, events however respond to something changing. The event of darkness falling will turn on lights, but I can always decide to turn the lights off. Unless you specificly program for this situation, PLC’s would immediately turn the lights back on again (as it is still dark). Home Assistant would not unless an event triggers another automation. That to me is desired behavior for my home.

Back on topic - applying a language that is designed for a different paradigm would be hard to impossible. At best it would lead to confusing behavior, because logic beneath does not match the expected behavior. Unless you try to fight the behavior, but then the implementation becomes a mess.

I think you are struggeling with Node Red for the same reasons - you are trying to apply PLC thinking to a differently designed system. Most likely you’ll run into the same problem with native automations, until you start thinking event driven instead of pure rule based.

1 Like

Thank you for your thoughts.
When you say i’m thinking like a PLC you’re right.
Generally i’m a visual person and maybe if there would be GUI which later interprets the automations would be useful.

This might be the solution you’re looking for. And/or gates. The examples in this one have locked in circuits(latching)

Ladder logic does make your automations a bit more organized because you’re writing to one output. The thing about yaml is sometimes I have to write 2 automations for one. For example the other day I made a bed sensor to run a script but I only wanted the script to run once so I had to create a input boolean to toggle on when the bed sensor was activated and if the toggle was on the automation wouldn’t run again. Then I needed to reset the input boolean with another automation. But that would be solved with ladder

Sequential function chart would be the best way to be honest

Home Assistant automations are state (or event) driven. You write the automation for each input, not output.

That sounds unnecessary. Just add a condition to only run once per day or whatever period of time you want. e.g.

condition:  # only run once per 24 hours
  - condition: template
    value_template: "{{ now() - this.attributes.last_triggered|default(as_datetime(0),1) > timedelta(days=1) }}"
3 Likes

good point, I guess i didnt think about using a template condition

I’m happy for you if things in your home happen in fairly predictable sequences. In my home they surely don’t. :wink: So I’m happy I can automate for chaotic occurring events.

haha is anyone truly happy? lol I should rephrase, i mean it would be sweet to set it up like sequential function chart so step one was always waiting for a trigger and then you build your automation with the same UI as sequential function chart

It isn’t a graph and I’m no expert, but I think you can pretty much do anything in an automation that is possible in a sequential function chart. However, it would probably include wait for trigger actions. I’m not a fan of those, because you can easily break them out into a separate automation. I don’t like hidden triggers, that are also at risk of being broken by a reload.

I’m an automation engineer and understand what @Herowinger tries to point out. It makes sense when you know that historically 61131-3 was born to make the transition easy from electrical drawing to PLC. At that time, PLC were so popular that 61131-3 was immediately adopted by the whole industry (including building automation by the way :wink:).

But reading this thread frustrated me a bit because it gives the impression that resolving complex automation tasks is reserved for people with IT background. Are you an enthusiastic electrician willing to solve a complex task that build-in HA automation can’t? too bad for you, you have to be familiar first with YAML, Python, Node-RED… But there are several good reasons to integrate “61131-3” in HA:

  1. It would include a larger community. How many hesitate because of the IT barrier?
  2. It is a programming standard developed by IEC and taught worldwide. No dark, home made language developed by someone in his basement.
  3. It covers many languages from the simple LD to more complex such as ST (closed to Pascal). Where the first would be largely used by people with electrical background, and the second by people with IT background. Everybody’s happy :partying_face:

There are already good solutions out there (e.g. OpenPLC) that Home Assistant can opt as an add-on. The tricky part is to integrate HA variables to such IDE. But I’ll live that to the experts…

1 Like