Giter Club home page Giter Club logo

omronplc_to_home_assistant's Introduction

What?

This program fetches data from Omron PLC and feeds it into Home Assistant via Auto Discovery

How?

I have an old Omron PLC that is used for home automation. This PLC is +20 years old but still works like a charm!
The only drawback, it doesn't have an IP interface! As a solution I use a Moxa Nport 5501 Serial-to-IP converter.
This Moxa device enables me to talk to the PLC over TCP.

Setup

                                                Moxa Nport 5501      -------->   Omron PLC C200H
                                                     |
                                                     |
                                                     |
                            Synology NAS running the Python code in a cronjob <----- CSV file as input.
                                                     |
                                                     |
                                                     |
                                    MQTT Broker (running on Home Assistant)
                                                     |
                                                     |
                                                     |                                                                                                 
                                        Home assistant (Raspberry Pi 4)                                      

The script will send the 'read' commands towards the PLC to read out the bit state data. I uses a CSV file as input.
This data (=symbols) can be exported if you use CX Programmer for example to edit your PLC program.
It simply contains the list of all BOOL bits that represent the state of an output.

CSV input file

Name;Data Type;Address;Comment;Extra
Light1;BOOL;191.01;This is light1;
Light2;BOOL;191.02;This is light2;

From bit data to MQTT to Home Assistant

191.01 -> represents the address in memory of the PLC. If this bit is 1, the light is ON. If this bit is 0 the light is OFF.
The code will connect to the PLC. Read & validate the data and send the results to the MQTT broker.


Screenshots in Docu:

The MQTT config message, needed for Home Assistant to understand the device settings:
Screenshot MQTT config message
The MQTT state message, needed for Home Assistant to know the state:
Screenshot MQTT state message
The Moxa Serial-2-IP connector
Screenshot showing the Moxa TCP Server mode settings
The Moxa Serial-2-IP connector TCP Server mode settings
Screenshot showing the Moxa TCP Server mode settings

omronplc_to_home_assistant's People

Contributors

angeraer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.