Integrating Siemens PLC with Node-RED for Home Lighting Control

I’ve been working on a project to integrate my Siemens PLC with Node-RED for controlling the lights in my home. It’s been an exciting journey, but I’ve hit a few bumps along the way. Let me share my experience and some insights that might help others facing similar challenges. The Setup I’ve set up a Siemens S7 PLC to manage all the lights in my house. Using Node-RED, I’ve established communication between the PLC and my Home Assistant (HA) system. This setup allows me to exchange data types like booleans and words between the two systems. It’s working great for sending commands, but I’m struggling with getting real-time feedback from the PLC to update the HA interface. The Challenge The issue arises with the feedback mechanism. My house uses physical buttons that toggle inputs on the PLC. The PLC detects a positive edge of the signal to switch the light on or off. I want this functionality replicated in the HA interface. Specifically, I need a button on the HA dashboard that sends a short 250ms signal to the PLC when pressed, and then updates its color to reflect the light’s current state. What I’ve Tried I’ve configured the PLC to detect the positive edge and switch the light accordingly. The status of the light is sent back to Node-RED, but integrating this feedback into the HA interface has been tricky. I’ve experimented with different Node-RED flows to handle the signal timing and state updates, but I’m not quite there yet. Seeking Solutions I’m looking for a working example of a Node-RED flow that can handle this kind of interaction. If anyone has experience with similar setups, I’d greatly appreciate any tips or code snippets. Understanding how to structure the flow for sending the short signal and updating the UI in real-time would be incredibly helpful. The Vision My ultimate goal is to have a seamless integration where pressing a button in HA sends the correct signal to the PLC, which then updates the UI to reflect the new state. This would make controlling the lights as intuitive as using the physical buttons in my house. If anyone has successfully implemented something like this, I’d love to hear about your approach. Let’s collaborate to make this project a success!