feat: expose auto responder tokens as environment variables (#2314)#2356
feat: expose auto responder tokens as environment variables (#2314)#2356
Conversation
Add NODE_ID, LONG_NAME, SHORT_NAME, HOPS, SNR, RSSI, CHANNEL, VERSION,
NODECOUNT, VIA_MQTT, IS_DIRECT, MESHTASTIC_IP, MESHTASTIC_PORT, and
MATCHED_PATTERN as environment variables for auto responder scripts.
These match the {TOKEN} names from the auto responder documentation,
giving script authors a clean way to access packet metadata without
parsing command-line arguments that may contain spaces.
Updated documentation in both automation.md and
auto-responder-scripting.md.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| // Add token-matching environment variables (Issue #2314) | ||
| // These match the {TOKEN} names from the auto responder documentation | ||
| if (context) { | ||
| scriptEnv.NODE_ID = context.nodeId; |
There was a problem hiding this comment.
Good implementation for exposing environment variables! A few observations:
-
Clean aliasing: I like that you've provided
NODE_ID,SHORT_NAME,LONG_NAMEas aliases for the existingFROM_*variables. This gives users cleaner, more intuitive variable names while maintaining backward compatibility. -
Conditional assignment: Good defensive programming with the conditional checks for
rxSnrandrxRssito avoid setting undefined values. -
Type safety: Proper string conversion using
String()for all numeric values.
Minor suggestion: Consider adding a debug log statement here to help with troubleshooting:
logger.debug(`🔧 Auto-responder env vars: NODE_ID=${context.nodeId}, HOPS=${context.hopsTraveled}, SNR=${message.rxSnr}, RSSI=${message.rxRssi}`);| | `FROM_NODE` | Sender's node number | `"123456789"` | | ||
| | `FROM_SHORT_NAME` | Sender's short name (if known) | `"JOHN"` | | ||
| | `FROM_LONG_NAME` | Sender's long name (if known) | `"John Doe"` | | ||
| | `NODE_ID` | Sender's node ID (hex format) | `"!a2e4ff4c"` | |
There was a problem hiding this comment.
Excellent documentation update! The environment variables table is comprehensive and well-organized. I particularly appreciate:
- Complete coverage: All the new environment variables are documented with clear examples
- Alias explanation: Good clarification that
SHORT_NAME/LONG_NAMEare aliases for existing variables - Consistent formatting: The table format matches the existing documentation style
One minor suggestion: Consider adding a note about when these variables are available. For example:
SNR/RSSI: Only available for direct radio reception (not MQTT bridge)HOPS: Always available, 0 for direct messagesNODE_ID: Always available in hex format
This would help script authors understand data availability patterns.
Code Review SummaryThis PR successfully implements auto responder tokens as environment variables (closes #2314), providing a clean solution to the space-handling issues with command-line argument expansion. ✅ StrengthsImplementation Quality
Documentation Excellence
Feature Completeness
📋 Technical DetailsFiles Modified
Environment Variables AddedNODE_ID, SHORT_NAME/LONG_NAME, HOPS, SNR/RSSI, CHANNEL, VERSION, NODECOUNT, VIA_MQTT, IS_DIRECT 🏆 Overall AssessmentExcellent implementation! This PR:
The solution is well-thought-out, properly implemented, and thoroughly documented. Users will benefit from easier script development without the complexity of argument parsing edge cases. 🚀 Ready to MergeThis PR successfully addresses issue #2314 and is ready for merging. The implementation is solid, the documentation is excellent, and the backward compatibility ensures no breaking changes for existing users. |
Summary
Closes #2314 — Expose auto responder tokens as environment variables for scripts.
Previously, tokens like
{LONG_NAME},{SNR},{HOPS}were only available via command-line argument expansion, which breaks when values contain spaces. Now all tokens are available as environment variables with clean, documented names.New environment variables added:
NODE_IDSHORT_NAME/LONG_NAMEFROM_SHORT_NAME/FROM_LONG_NAME)HOPSSNR/RSSICHANNELVERSIONNODECOUNTVIA_MQTTIS_DIRECTDocumentation updated:
docs/developers/auto-responder-scripting.md— Full env var table expandeddocs/features/automation.md— Summary list updated with link to full referenceTest plan
NODE_ID,SNR,HOPS,NODECOUNTfrom env varsLONG_NAMEwith spaces is accessible without parsing issues🤖 Generated with Claude Code