Skip to content

Conversation

@lucagem
Copy link

@lucagem lucagem commented Jun 27, 2025

Summary

Added dynamic endpoint configuration

✨ New Features

Dynamic endpoint configuration

S7 Endpoint Configuration Interface

The image above shows the enhanced S7 endpoint configuration interface with numbered references to the new and modified features:

1. Address Field (Existing)

Standard IP address configuration for the PLC connection. This field was already functional and no modifications were made.

  • Fixed value eg: 10.0.0.102
  • Environment variable: ${S7_IP}
  • Custom environment variable: ${YOUR_PORT_VAR}

2. Port Field (Enhanced)

Enhanced with environment variable support:

  • Fixed value default: 102
  • Environment variable: ${S7_PORT}
  • Custom environment variable: ${YOUR_PORT_VAR}

3. Rack Field (Enhanced)

Enhanced with environment variable support:

  • Fixed value default: 0
  • Environment variable: ${S7_RACK}
  • Custom environment variable: ${YOUR_RACK_VAR}

4. Slot Field (Enhanced)

Enhanced with environment variable support:

  • Fixed value default: 2
  • Environment variable: ${S7_SLOT}
  • Custom environment variable: ${YOUR_SLOT_VAR}

5. PLC Enabled Field (NEW)

New field for dynamic PLC enable/disable:

  • Empty or true: PLC enabled (default behavior)
  • false or 0: PLC disabled
  • ${S7_ENABLE}: Environment variable
  • Custom environment variable: ${YOUR_ENABLE_VAR}

When PLC is disabled:

  • The endpoint remains in "offline" state
  • Write operations fail with "PLC disabled" error
  • No connection attempts are made

6. CSV File Path Field (NEW)

New field for external variable configuration:

  • Absolute path: C:\config\s7_tags.csv
  • Relative path: ./config/tags.csv
  • Environment variable: ${S7_CSV_FILE}
  • Custom environment variable: ${YOUR_CSV_VAR}

Dynamic Configuration Management

CSV File Loading

The CSV file allows loading the variable list from an external file instead of the node configuration. This facilitates:

  • Reusing the same configuration across different installations
  • Centralized tag management
  • Synchronization with external configuration systems

CSV file format:

address<TAB|;>name
DB1,REAL0	Temperature_1
DB1,REAL4	Temperature_2
MB100	Memory_Byte_100

The CSV file takes priority over internal configuration. If the file doesn't exist or is empty, the node configuration is used.

Environment Variables Benefits

Using environment variables for fields 1-6 allows configuring different environments (development, test, production) using the same flow but with different connection parameters.

Technical Notes

  • Environment variables are automatically resolved by Node-RED
  • CSV loading occurs only at node startup
  • In case of CSV errors, the node configuration is used with a warning message
  • CSV parsing supports TAB ( ) and semicolon (;) separators
  • Empty lines in CSV are ignored
  • Fields 2, 3, 4 maintain backward compatibility with numeric values
  • Fields 5 and 6 are completely new additions

@lucagem lucagem marked this pull request as draft June 27, 2025 09:21
- Add PLC enabled/disabled functionality via env variable
- Add CSV file loading for variable definitions via variable
- Add environment variable support for Port, Rack, Slot parameters
- Maintain backward compatibility with existing configurations
- Add comprehensive error handling and logging
- Update documentation with usage examples and technical notes
@lucagem lucagem force-pushed the feature/dynamyc-enable-csv-load branch from 5801f8c to 05b26aa Compare June 30, 2025 09:42
@lucagem lucagem marked this pull request as ready for review June 30, 2025 10:13
@lucagem
Copy link
Author

lucagem commented Sep 18, 2025

🔄 Updated to latest master (v3.1.0)

Hi maintainers! 👋

This PR has been automatically updated to be fully compatible with the latest master branch.

Why this feature is valuable:

  • Multi-environment support - Same flows work across dev/staging/production
  • CSV configuration - Centralized tag management for enterprise deployments
  • Zero breaking changes - Fully backward compatible
  • Production-ready - Addresses real industrial automation challenges

The dynamic configuration capabilities (environment variables + CSV loading) are highly requested features in industrial Node-RED deployments.

Ready for review - Happy to address any feedback! 🙏

Thanks for maintaining this excellent S7 library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant