Skip to content
Projets

À propos

Home Assistant Integration for S7 PLCs

Productivité et automatisation

Comment ces chiffres sont mesurés

What you can do

  • ⚡ Direct PLC communication over S7 protocol via pys7
  • 🧩 Multiple entity types: light, dimmer light, switch, cover, button, binary_sensor, sensor, number, select, text, climate, and Entity Sync
  • 🔌 Dual connection modes: Rack/Slot or TSAP addressing
  • 🧮 Value multipliers: Scale raw PLC values before Home Assistant sees them

Progression mesurée des étoiles

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

ha-s7plc

Home Assistant integration for Siemens S7 PLCs and Logo! controllers
Direct + lightweight custom component using pys7.
No MQTT • No REST • No middleware


ha-s7plc banner


Release Home Assistant Python pyS7


Buy Me A Coffee

Quick Links ✨ Features • 🚀 Quick Start • 📚 Documentation • 🧩 Entities • 🛠️ Troubleshooting • 📊 PLC Survey


📊 Help improve PLC compatibility

Which Siemens PLC are you using with ha-s7plc?

Take our short voluntary survey and help us understand which PLC models and firmware versions are actually used by the community.

👉 Take the PLC Compatibility Survey

No information is collected automatically from Home Assistant or your PLC.


Features

  • ⚡ Direct PLC communication over S7 protocol via pys7
  • 🧩 Multiple entity types: light, dimmer light, switch, cover, button, binary_sensor, sensor, number, select, text, climate, and Entity Sync
  • 🔌 Dual connection modes: Rack/Slot or TSAP addressing
  • 🧮 Value multipliers: Scale raw PLC values before Home Assistant sees them
  • 🪶 Lightweight: Minimal overhead, no broker/services required
  • 🛠️ Full UI configuration: Set up and manage entirely from Home Assistant's UI
  • 🖥️ Native side panel: Manage every PLC entity from the Home Assistant sidebar with visual and YAML editors, live states, and validation
  • 🕒 Schedule dashboard card: Edit BCD WORD or HHMM on/off times with a visual card editor, automatically loaded with the integration (guide)
  • 🔍 Optional auto-discovery: Pre-populates PLCs found on your local network
  • 📄 S7 STRING support for text sensors
  • 🔄 State synchronization: Bidirectional sync for switches and lights with physical controls
  • 📤 Entity Sync: Push any Home Assistant entity state to PLC addresses in real-time
  • 🌡️ Climate control: Direct control and setpoint modes for HVAC systems
  • 📊 Import/Export: Backup and restore your entity configurations
  • 📈 Performance metrics: Optional diagnostic sensors for connection health and PLC communication stats

🖥️ Everything in one side panel

S7 PLC side panel with the PLC header, the category sidebar and sensor cards showing live values

Guided entity editor with the address builder and the live value Connection details with the 24-hour availability timeline
Guided editor: build PLC addresses visually and check the live value Connection diagnostics: availability, uptime and every connection parameter

Search, filter and edit every PLC entity, switch between PLCs, bulk-delete, back up the whole configuration as YAML and spot unavailable entities at a glance. See the Side Panel Guide.


Quick Start

Requirements

  • Home Assistant installation
  • Siemens S7 PLC (S7-1200/1500/300/400) or Logo! controller (Logo! 8 / 0BA8 and newer; Logo! 0BA7 and older via TSAP) reachable over ISO-on-TCP (port 102)
  • Network connectivity between Home Assistant and PLC
  • pyS7 3.1.2, installed automatically by Home Assistant

ℹ️ For S7-1200/1500: Ensure data blocks have Optimized block access disabled if using absolute addressing. ℹ️ For Logo! 8 (0BA8+): use Rack/Slot connection (rack: 0, slot: 2). For Logo! 0BA7 and older: use TSAP connection (see addressing docs).

Installation

Via HACS (Recommended)

  1. Ensure HACS is installed
  2. Open HACS → Integrations
  3. Search for "Siemens S7 PLC" and install
  4. Restart Home Assistant

Manual Installation

  1. Copy custom_components/s7plc to your HA config directory
  2. Restart Home Assistant

Basic Setup

[!IMPORTANT] Entity management through the legacy Entity Options Flow was removed in version 7.0.0. The initial Config Flow and the connection Options Flow remain available; entities are managed only through the S7 PLC Side Panel.

  1. Install the integration and restart Home Assistant.
  2. Go to Settings → Devices & Services → Add Integration.
  3. Search for and add S7 PLC.
  4. Choose connection type:
    • Rack/Slot (default): Standard connection for most PLCs and Logo! 8
    • TSAP: For specific configurations, Logo! 0BA7 and older, or legacy systems
  5. Enter the PLC connection details and let the Config Flow verify the connection:
    • Host, Port
    • Rack/Slot (typically 0/1 for S7-1200/1500, 0/2 for S7-300/400 and Logo! 8)
    • or Local/Remote TSAP for TSAP mode (e.g. 10.00 / 10.01 for Logo! 0BA7)
  6. Configure timeout and retry settings for your network.
  7. Open S7 PLC from the Home Assistant sidebar, then add and manage entities in the Side Panel.

Connection status after setup: The setup connection test is temporary. Until a read, write, or explicit health check is requested, a newly added PLC with no configured entities normally shows Disconnected. This is expected and does not mean the setup test failed. See on-demand connections.

Changing the Connection

Settings → Devices & Services → S7 PLC → Configure opens the Options Flow exclusively for connection settings: name, host and port, Rack/Slot or TSAP parameters for the connection method selected during setup, pyS7 connection type, global scan interval, timeout, retry and backoff, optimized reads, write batching, and metrics. It does not manage entities. The Rack/Slot ↔ TSAP connection method itself cannot be changed later; create a new integration entry to use the other method.


Documentation

Comprehensive documentation is available in the docs/ directory:

Quick Links

Topic Description
Connection Types Rack/Slot vs TSAP addressing
Entity Types Switch, Light, Dimmer Light, Cover, Sensor, Number, Climate, Entity Sync
S7 PLC Side Panel Visual/YAML editing, validation, live status, and multi-PLC selection
Value Conversions Read/write scaling, clamping, and custom expressions
State Sync Bidirectional synchronization for physical controls
Entity Sync Push HA entities to PLC addresses
Performance Metrics Diagnostic sensors for connection and communication stats
Logo! Support Specific notes for Logo! controllers
Export/Import Backup and restore configurations

Supported Entities

Entity Type Read Write Features
Binary Sensor ✅ ❌ Device classes, bit addressing, numeric comparisons, state inversion
Sensor ✅ ❌ Numeric types, strings, multipliers, precision
Switch ✅ ✅ State sync, pulse command mode, separate state/command addresses
Light (On/Off) ✅ ✅ State sync, pulse command mode, separate state/command addresses
Dimmer Light ✅ ✅ Brightness control, configurable scale, optional actuator relay
Cover ✅ ✅ Open/close commands, position control (0–100%), stop, timing
Button ❌ ✅ Pulse output with configurable duration (0.1-60s, supports decimals)
Number ✅ ✅ Min/max/step, separate read/write addresses
Select ✅ ✅ Map numeric PLC values to named options (modes, fan speeds, etc.)
Text ✅ ✅ STRING/WSTRING support, pattern validation, auto-sized limits
Climate ✅ ✅ Direct control or setpoint mode, HVAC status feedback
Entity Sync ❌ ✅ Monitor any HA entity, write to PLC on change

Supported Data Types

S7 Type Example Description
Bit DB1,X0.0 Boolean values
Byte DB1,B0 Unsigned 8-bit (0-255)
USInt DB1,USINT0 Unsigned 8-bit (0-255, explicit USINT)
SInt DB1,SINT0 Signed 8-bit (-128 to 127)
Char DB1,C0 Single Latin-1 character
Word DB1,W2 Unsigned 16-bit (0-65535)
Int DB1,I2 Signed 16-bit (-32768 to 32767)
DWord DB1,DW4 Unsigned 32-bit (0-4294967295)
DInt DB1,DI4 Signed 32-bit (-2147483648 to 2147483647)
Real DB1,R4 IEEE 754 32-bit float
LReal DB1,LR8 IEEE 754 64-bit double precision float
String DB1,S0.20 S7 STRING type (Latin-1)
WString DB1,WS0.20 S7 WSTRING type (Unicode UTF-16)

Note: Use I/DI for signed integers, W/DW for unsigned integers. Use SINT for signed 8-bit values.

See S7 Addressing for complete details.


Example Use Cases

  • HVAC Control: Read temperatures, control setpoints, climate entities with direct or setpoint modes
  • Lighting Systems: Multi-point control with physical switches, dimmer lights with brightness control
  • Conveyor Belts: Monitor status, control motors
  • Door Access: Lock control, contact monitoring
  • Data Logging: Push weather, energy data to PLC
  • Process Control: Tank levels, valve positions, pump control

See Examples for detailed configurations.


FAQ

Q: Is MQTT required?
A: No. Direct S7 protocol communication to PLC.

Q: Which PLCs are supported?
A: Any Siemens device with ISO-on-TCP (port 102) support: S7-1200, S7-1500, S7-300, S7-400, Logo! 8 (0BA8+) via Rack/Slot, and Logo! 0BA7/0BA6/0BA5 via TSAP.

Q: Can I write values to the PLC?
A: Yes. switch, light, dimmer light, cover, button, number, select, text, climate, and Entity Sync all support writes.

Q: Do I need to know PLC programming?
A: Basic knowledge helps. You need to know your data block structure and addresses.

Q: Can I use symbolic names?
A: No, only absolute addressing (DB + offset) is supported.


Troubleshooting

Common issues:

  • Connection fails: Check network, firewall, rack/slot values
  • Wrong values: Verify address, data type, alignment
  • Slow updates: Adjust scan interval, check network latency
  • Intermittent disconnects: Review timeout settings, network stability

See Troubleshooting Guide for complete solutions.


Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes with clear commit messages
  4. Add documentation for new features
  5. Open a Pull Request

Development

Local development requires Python and Node.js. Install both dependency sets and run the backend and panel DOM test suites:

python -m pip install -r requirements_dev.txt
npm ci

python -m pytest tests -v
npm run test:panel

See CONTRIBUTING.md for the complete environment setup, focused test commands, frontend test structure, coverage checks, and pull request guidelines.

This project also uses pre-commit:

pre-commit run --files <file1> [<file2> ...]

Roadmap

  • Multiple entity types
  • UI-only configuration
  • State synchronization
  • Entity sync (write HA entities to PLC)
  • TSAP connection support
  • Import/Export configuration
  • Climate entities (direct and setpoint control)
  • Dimmer light with brightness control
  • Position-based cover with stop
  • Performance metrics (diagnostic sensors)
  • Performance optimizations

Have ideas? Open an issue or PR!


Releases

7.0.0

Version 7.0.0 makes the native S7 PLC Side Panel the primary workspace for managing connections and entities. It provides selectable tabbed and expandable all-entity layouts, guided simplified modes for switches, on/off and dimmable lights, traditional and position covers, and direct or setpoint climates, plus Advanced YAML import/export. The previous entity Options Flow has been removed; the remaining Options Flow edits connection parameters only. Its Rack/Slot or TSAP method remains fixed after initial setup.

Traditional covers can now derive position from a single open or closed limit switch, both limit switches, timed estimation, or mapped status-word values. Movement feedback can likewise use individual bits or a status word. Entities also gain configurable availability policies: follow the PLC connection and required data, remain available with the last known state, or require a PLC BIT. The panel's connection detail view now provides clearer diagnostics, including the active pyS7 version and communication settings.

Existing 6.5.x config entries, entity definitions, and UIDs remain compatible; there is no destructive data migration and no need to recreate entities. After upgrading and restarting Home Assistant, use the Side Panel instead of the old entity Options Flow. As always, exporting an entity backup before a major upgrade is recommended. The integration now requires pys7==3.1.1.

Breaking change / user action: entity editing in the legacy Options Flow is no longer available. No configuration conversion is required, but entity changes must now be made in the Side Panel. To change between Rack/Slot and TSAP, create a new integration entry.

See Releases for downloads and earlier release notes.


Security & Safety

  • Use on trusted networks only
  • Apply standard Home Assistant secrets handling
  • Consider read-only DBs for monitoring to prevent accidental writes
  • Test thoroughly in non-production environments first

License

This project is licensed under the MIT License - see LICENSE for details.


Acknowledgements

  • Built on pyS7 library
  • Inspired by the Home Assistant community
  • Not affiliated with Siemens AG or Home Assistant

Support

Explorer des projets similaires

Chargement…