HAP-NodeJS
HAP-NodeJS copied to clipboard
Special Characters in Name
Analysis
@Supereg With the recent IOS versions I have noticed that accessory names are now being checked for special characters or emoji, and am thinking that we should add an error or warning message when these are being used. I was using (
and )
, but there are likely others. I did find that -
did not trigger the message
Am wondering if this is a potential trigger of this issue - https://github.com/homebridge/homebridge/issues/3373#issuecomment-1558438317
Expected Behavior
An error or warning message to be logged when a accessory name contains an unsupported character.
Steps To Reproduce
Create an accessory with invalid character
Logs
None
Configuration
not needed
Environment
- OS:
- Software:
- Node:
- npm:
Process Supervisor
hb-service
Additional Context
No response
This has always been the case and have code to validate names on my stuff
https://developer.apple.com/design/human-interface-guidelines/homekit
Use only alphanumeric, space, and apostrophe characters. Start and end with an alphabetic or numeric character. Don’t include emojis.
I have a function like this
function validateHomeKitName(nameToMakeValid) {
// Strip invalid characters to meet HomeKit naming requirements
// Ensure only letters or numbers are at the beginning AND/OR end of string
return nameToMakeValid.replace(/[^A-Za-z0-9 ,.-]/g, "").replace(/^[^a-zA-Z0-9]*/g, "").replace(/[^a-zA-Z0-9]+$/g, "");
}
HomeKit also chokes on a Manufacturer Name with a /
.
We might extend the sanity checks we already have in Accessory.validateAccessory
. There we check for empty values for those Characteristics.
I'm not sure if it makes sense to automatically alter names(?). We could offer some help if they attempt it in Homebridge UI, but we can't really prevent it, if they configure accessory names via the config themselves.
@Supereg Am thinking your recommendation to extend Accessory.validateAccessory with the check creating a log entry makes the most sense. Something similar to the existing checks.
Give me a few days, and I will submit a pull request.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Not stale
I wonder if the current implementation is too restrictive, as dash or punctuation are a) not uncommon and b) supported by HomeKit.
Rolling out this change as is may result in a lot of confusion (and many people goint to rework their setup, even if it is not needed).
@muenzpraeger see above https://github.com/homebridge/HAP-NodeJS/issues/1008#issuecomment-1608825576
I'm aware of the HIG reference. Now, I've at least 40 different accessories that have a special character (.
or -
) in their name, and now I'm being spammed on startup.
I'd say it's ok for doing a validation check when a new accessory is created. Not for existing devices. Alternatively the option should be available to disable this warning.
@muenzpraeger What happens when you edit the name in the Home app ? I found that I couldn't save the edited name, hence us adding the warning.
Works for me (at least with .
and -
. Video is low-res b/c of GitHub file limits.
https://github.com/user-attachments/assets/e7a87d1c-4497-485d-a497-dbbf9d7d95b7