-
Notifications
You must be signed in to change notification settings - Fork 81
DO NOT MERGE - Add validation and warning for modified Shelly device IDs with invalid MAC addresses #1255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
2
commits into
master
Choose a base branch
from
copilot/fix-6afd770f-9198-4863-937c-1c6f790b4abf
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Added isValidMacAddress() method to validate serial ID format - Added validateDeviceId() method to log warning for invalid MACs - Integrated validation in MQTT and CoAP client initialization - Added comprehensive tests for validation functionality - Addresses issue where modified device IDs like "shellyplusuni#regentonne" now trigger warnings Co-authored-by: GermanBluefox <[email protected]>
Copilot finished work on behalf of
GermanBluefox
October 3, 2025 11:10
Look like there has been much more code added / change sthan to require the check at mqtt. ON HOLD _ DO NOT MERGE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
This PR implements validation to detect and warn users when Shelly device IDs contain invalid MAC address formats in the serial ID portion. This addresses cases where users have manually modified device IDs with custom names instead of proper MAC addresses.
Problem
Users may modify Shelly device IDs to use custom identifiers (e.g.,
shellyplusuni#regentonne
instead ofshellyplusuni#A4CF12F454A3
). While these modified IDs may work in some cases, they don't follow the standard Shelly device naming convention where the serial portion should be a valid MAC address in hexadecimal format. This can lead to confusion and potential issues.Solution
Added automatic validation that checks device IDs when devices connect via MQTT or CoAP protocols. If an invalid MAC address format is detected, a clear warning is logged:
Implementation Details
Core validation logic (
lib/protocol/base.js
):isValidMacAddress(serialId)
: Validates that serial IDs contain only hexadecimal characters (0-9, A-F, a-f) with minimum 6 character lengthvalidateDeviceId()
: Checks device IDs and logs warnings for invalid formatsIntegration points:
start()
methodNon-breaking change: Only logs warnings; devices continue to function normally
Testing
Added comprehensive test suite with 7 new test cases covering:
All tests passing (18 total: 11 existing + 7 new)
ESLint validation passes with no errors
Examples
Valid device IDs (no warning):
SHBDUO-1#8CAAB5616291#2
SHRGBW2#C45BBE798F0F#1
shellypro2pm#30c6f7850a64#1
Invalid device IDs (warning logged):
shellyplusuni#regentonne#1
(from issue)SHELLY#my-device#1
SHELLY#test123#1
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.