Skip to content
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

Implement warning messages for invalid characters in names #1009

Merged
merged 6 commits into from
Jun 23, 2024

Conversation

NorthernMan54
Copy link
Contributor

♻️ Current situation

Invalid characters in names will trigger warning messages in the Home App. #1008

💡 Proposed solution

Implement warning messages for invalid characters in names

Sample warning messages

HAP-NodeJS WARNING: The service 'Play (Yamaha)' is getting published with the characteristic 'Name' not following HomeKit naming rules ('Play (Yamaha)'). Use only alphanumeric, space, and apostrophe characters, start and end with an alphabetic or numeric character, and don't include emojis. This might prevent the accessory from being added to the Home App or leading to the accessory being unresponsive!
HAP-NodeJS WARNING: The service 'Pause (Yamaha)' is getting published with the characteristic 'Name' not following HomeKit naming rules ('Pause (Yamaha)'). Use only alphanumeric, space, and apostrophe characters, start and end with an alphabetic or numeric character, and don't include emojis. This might prevent the accessory from being added to the Home App or leading to the accessory being unresponsive!
HAP-NodeJS WARNING: The service 'Skip Fwd (Yamaha)' is getting published with the characteristic 'Name' not following HomeKit naming rules ('Skip Fwd (Yamaha)'). Use only alphanumeric, space, and apostrophe characters, start and end with an alphabetic or numeric character, and don't include emojis. This might prevent the accessory from being added to the Home App or leading to the accessory being unresponsive!
HAP-NodeJS WARNING: The service 'Skip Rev (Yamaha)' is getting published with the characteristic 'Name' not following HomeKit naming rules ('Skip Rev (Yamaha)'). Use only alphanumeric, space, and apostrophe characters, start and end with an alphabetic or numeric character, and don't include emojis. This might prevent the accessory from being added to the Home App or leading to the accessory being unresponsive!
HAP-NodeJS WARNING: The accessory 'Spotify (Yamaha)' is getting published with the characteristic 'name' not following HomeKit naming rules ('Spotify (Yamaha)'). Use only alphanumeric, space, and apostrophe characters, start and end with an alphabetic or numeric character, and don't include emojis. This might prevent the accessory from being added to the Home App or leading to the accessory being unresponsive!

⚙️ Release Notes

Warning messages will now be logged for names containing invalid characters

➕ Additional Information

If applicable, provide additional context in this section.

Testing

Testing has been augmented with test cases for the various scenarios.

Output from testing with one of my plugins that has the issue.

HAP-NodeJS WARNING: The service 'Play (Yamaha)' is getting published with the characteristic 'Name' not following HomeKit naming rules ('Play (Yamaha)'). Use only alphanumeric, space, and apostrophe characters, start and end with an alphabetic or numeric character, and don't include emojis. This might prevent the accessory from being added to the Home App or leading to the accessory being unresponsive!
HAP-NodeJS WARNING: The service 'Pause (Yamaha)' is getting published with the characteristic 'Name' not following HomeKit naming rules ('Pause (Yamaha)'). Use only alphanumeric, space, and apostrophe characters, start and end with an alphabetic or numeric character, and don't include emojis. This might prevent the accessory from being added to the Home App or leading to the accessory being unresponsive!
HAP-NodeJS WARNING: The service 'Skip Fwd (Yamaha)' is getting published with the characteristic 'Name' not following HomeKit naming rules ('Skip Fwd (Yamaha)'). Use only alphanumeric, space, and apostrophe characters, start and end with an alphabetic or numeric character, and don't include emojis. This might prevent the accessory from being added to the Home App or leading to the accessory being unresponsive!
HAP-NodeJS WARNING: The service 'Skip Rev (Yamaha)' is getting published with the characteristic 'Name' not following HomeKit naming rules ('Skip Rev (Yamaha)'). Use only alphanumeric, space, and apostrophe characters, start and end with an alphabetic or numeric character, and don't include emojis. This might prevent the accessory from being added to the Home App or leading to the accessory being unresponsive!
HAP-NodeJS WARNING: The accessory 'Spotify (Yamaha)' is getting published with the characteristic 'name' not following HomeKit naming rules ('Spotify (Yamaha)'). Use only alphanumeric, space, and apostrophe characters, start and end with an alphabetic or numeric character, and don't include emojis. This might prevent the accessory from being added to the Home App or leading to the accessory being unresponsive!

Reviewer Nudging

Where should the reviewer start? what is a good entry point?

@ebaauw @n0rt0nthec4t - Thanks for your input and feedback. I have tried to include

@NorthernMan54 NorthernMan54 linked an issue Jun 27, 2023 that may be closed by this pull request
@n0rt0nthec4t
Copy link

This almost needs to be at the characteristic level. An example being if you have an accessory which uses the Characteristic.ConfiguredName, setting this for HomeKit with invalid characters shows an error in HomeKit.

Copy link
Contributor

@ebaauw ebaauw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good to me.

src/lib/Accessory.ts Outdated Show resolved Hide resolved
ebaauw
ebaauw previously approved these changes Jun 28, 2023
src/lib/Accessory.spec.ts Show resolved Hide resolved
@NorthernMan54
Copy link
Contributor Author

@n0rt0nthec4t - Let me look at that later today. As HAP-NodeJS attempts to be transparent to individual characteristics it could be challenging.

PS - Need to fix my new tests, they don't allow jest to shutdown correctly.

@coveralls
Copy link

coveralls commented Jun 29, 2023

Pull Request Test Coverage Report for Build 5418498676

  • 16 of 16 (100.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.05%) to 65.066%

Totals Coverage Status
Change from base Build 4845506880: 0.05%
Covered Lines: 7412
Relevant Lines: 10610

💛 - Coveralls

Copy link
Member

@Supereg Supereg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for you work on this PR. 🚀

I think just allowing the base ASCII alphabet is maybe a bit restrictive?

package.json Outdated Show resolved Hide resolved
src/lib/Accessory.spec.ts Show resolved Hide resolved
src/lib/Service.ts Outdated Show resolved Hide resolved
src/lib/Accessory.ts Outdated Show resolved Hide resolved
@donavanbecker donavanbecker merged commit 63ef5c2 into homebridge:latest Jun 23, 2024
5 checks passed
donavanbecker added a commit that referenced this pull request Jun 23, 2024
- Implement warning messages for invalid characters in names (#1009) (@NorthernMan54)
- Mitigate event emitter "memory leak" warnings when a significant number of camera streaming events occur simultaneously (#1037) (@hjdhjd)
- Updated dependenies
donavanbecker added a commit that referenced this pull request Jun 23, 2024
- Implement warning messages for invalid characters in names (#1009) (@NorthernMan54)
- Mitigate event emitter "memory leak" warnings when a significant number of camera streaming events occur simultaneously (#1037) (@hjdhjd)
- Updated dependencies
@donavanbecker
Copy link
Contributor

donavanbecker commented Jun 23, 2024

@NorthernMan54 looks like the tests might be failing because of this?

https://github.com/homebridge/HAP-NodeJS/actions/runs/9630265250/job/26560643569

@NorthernMan54
Copy link
Contributor Author

If you look down the log, it is failing here - ● Test suite failed to run

src/lib/HAPServer.spec.ts:621:7 - error TS2578: Unused '@ts-expect-error' directive.

621       // @ts-expect-error: type mismatch
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Something unrelated...

@donavanbecker donavanbecker mentioned this pull request Jun 24, 2024
donavanbecker added a commit that referenced this pull request Jul 11, 2024
## v1.0.0 (2025-07-11)

### Breaking Changes

- **The minimum Node.js version required is now `v18`.**
- **Important notice:** Because of the cleanup of the Deprecated code, you will need to migrate you code base.
    - Remove the long-deprecated init().
    - Deprecate Core, BridgedCore, legacy Camera characteristics. (#1058) (@hjdhjd)
        - For deprecated `Core` and `BridgedCore` see: https://github.com/homebridge/HAP-NodeJS/wiki/Deprecation-of-Core-and-BridgeCore
    - Legacy code deprecation cleanup. (#1059) (@hjdhjd)
        - For deprecated `storagePath` switch to `HAPStorage.setCustomStoragePath`, `AudioCodec` switch to `AudioStreamingCodec`, `VideoCodec` switch to `H264CodecParameters`,`StreamAudioParams` switch to `AudioStreamingOptions`, `StreamVideoParams` switch to `VideoStreamingOptions`,`cameraSource` switch to `CameraController`.
    - Others deprecated code to highlight removed: `useLegacyAdvertiser`, `AccessoryLoader`,

### Fixed

- Fix: Build Issues (#1041) (@NorthernMan54)
- Fix: Ensure data is only transmitted on open and ready connections. (#1051) (@hjdhjd)
- Fix: Ensure we check names using the full UTF-8 character set. (#1052) (@hjdhjd)
- Fix: ConfiguredName (#1049) (@donavanbecker)
- Fix: Manufacturer looking at checkName but should look at checkValue. (#1053) (@donavanbecker)

### Other Changes

- Implement warning messages for invalid characters in names (#1009) (@NorthernMan54)
- Mitigate event emitter "memory leak" warnings when a significant number of camera streaming events occur simultaneously (#1037) (@hjdhjd)
- AdaptiveLightingController fix & improvement (#1038) (@Shaquu)
- Minor fixes to recording logging and one change in logging. (#1040) (@hjdhjd)
- Bridged core and core cleanup (#1048) (@Shaquu)
- Increase snapshot handler warning timeout to 8000ms. (#1055) (@hjdhjd)
- Cleanup and refactor getLocalNetworkInterface and address a potential edge case. (#1056) (@hjdhjd)
- Correct log spacing
- Updated and fixed `typedoc` config file
- Updated dependencies

### Homebridge Dependencies

- `@homebridge/ciao` @ `v1.3.0`
- `bonjour-hap` @ `v3.8.0`
donavanbecker added a commit that referenced this pull request Jul 11, 2024
- **The minimum Node.js version required is now `v18`.**
- **Important notice:** Because of the cleanup of the Deprecated code, you will need to migrate you code base.
    - Remove the long-deprecated init().
    - Deprecate Core, BridgedCore, legacy Camera characteristics. (#1058) (@hjdhjd)
        - For deprecated `Core` and `BridgedCore` see: https://github.com/homebridge/HAP-NodeJS/wiki/Deprecation-of-Core-and-BridgeCore
    - Legacy code deprecation cleanup. (#1059) (@hjdhjd)
        - For deprecated `storagePath` switch to `HAPStorage.setCustomStoragePath`, `AudioCodec` switch to `AudioStreamingCodec`, `VideoCodec` switch to `H264CodecParameters`,`StreamAudioParams` switch to `AudioStreamingOptions`, `StreamVideoParams` switch to `VideoStreamingOptions`,`cameraSource` switch to `CameraController`.
    - Others deprecated code to highlight removed: `useLegacyAdvertiser`, `AccessoryLoader`.
- Fix: Naming for Characteristic.ProgramMode has been corrected from `PROGRAM_SCHEDULED_MANUAL_MODE_` to `PROGRAM_SCHEDULED_MANUAL_MODE`

- Fix: Build Issues (#1041) (@NorthernMan54)
- Fix: Ensure data is only transmitted on open and ready connections. (#1051) (@hjdhjd)
- Fix: Ensure we check names using the full UTF-8 character set. (#1052) (@hjdhjd)
- Fix: ConfiguredName (#1049) (@donavanbecker)
- Fix: Manufacturer looking at checkName but should look at checkValue. (#1053) (@donavanbecker)

- Implement warning messages for invalid characters in names (#1009) (@NorthernMan54)
- Mitigate event emitter "memory leak" warnings when a significant number of camera streaming events occur simultaneously (#1037) (@hjdhjd)
- AdaptiveLightingController fix & improvement (#1038) (@Shaquu)
- Minor fixes to recording logging and one change in logging. (#1040) (@hjdhjd)
- Bridged core and core cleanup (#1048) (@Shaquu)
- Increase snapshot handler warning timeout to 8000ms. (#1055) (@hjdhjd)
- Cleanup and refactor getLocalNetworkInterface and address a potential edge case. (#1056) (@hjdhjd)
- Correct log spacing
- Updated and fixed `typedoc` config file
- Updated dependencies

- `@homebridge/ciao` @ `v1.3.0`
- `bonjour-hap` @ `v3.8.0`
donavanbecker added a commit that referenced this pull request Jul 11, 2024
## v1.0.0 (2024-07-10)

### Breaking Changes

- **The minimum Node.js version required is now `v18`.**
- **Important notice:** Because of the cleanup of the Deprecated code,
you will need to migrate you code base.
    - Remove the long-deprecated init().
- Deprecate Core, BridgedCore, legacy Camera characteristics. (#1058)
(@hjdhjd)
- For deprecated `Core` and `BridgedCore` see:
https://github.com/homebridge/HAP-NodeJS/wiki/Deprecation-of-Core-and-BridgeCore
    - Legacy code deprecation cleanup. (#1059) (@hjdhjd)
- For deprecated `storagePath` switch to
`HAPStorage.setCustomStoragePath`, `AudioCodec` switch to
`AudioStreamingCodec`, `VideoCodec` switch to
`H264CodecParameters`,`StreamAudioParams` switch to
`AudioStreamingOptions`, `StreamVideoParams` switch to
`VideoStreamingOptions`,`cameraSource` switch to `CameraController`.
- Others deprecated code to highlight removed: `useLegacyAdvertiser`,
`AccessoryLoader`.
- Fix: Naming for Characteristic.ProgramMode has been corrected from
`PROGRAM_SCHEDULED_MANUAL_MODE_` to `PROGRAM_SCHEDULED_MANUAL_MODE`

### Fixed

- Fix: Build Issues (#1041) (@NorthernMan54)
- Fix: Ensure data is only transmitted on open and ready connections.
(#1051) (@hjdhjd)
- Fix: Ensure we check names using the full UTF-8 character set. (#1052)
(@hjdhjd)
- Fix: ConfiguredName (#1049) (@donavanbecker)
- Fix: Manufacturer looking at checkName but should look at checkValue.
(#1053) (@donavanbecker)

### Other Changes

- Implement warning messages for invalid characters in names (#1009)
(@NorthernMan54)
- Mitigate event emitter "memory leak" warnings when a significant
number of camera streaming events occur simultaneously (#1037) (@hjdhjd)
- AdaptiveLightingController fix & improvement (#1038) (@Shaquu)
- Minor fixes to recording logging and one change in logging. (#1040)
(@hjdhjd)
- Bridged core and core cleanup (#1048) (@Shaquu)
- Increase snapshot handler warning timeout to 8000ms. (#1055) (@hjdhjd)
- Cleanup and refactor getLocalNetworkInterface and address a potential
edge case. (#1056) (@hjdhjd)
- Correct log spacing
- Updated and fixed `typedoc` config file
- Updated dependencies

### Homebridge Dependencies

- `@homebridge/ciao` @ `v1.3.0`
- `bonjour-hap` @ `v3.8.0`
@bwp91 bwp91 mentioned this pull request Jul 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Special Characters in Name
8 participants