Skip to content

Conversation

@PWhite-Eng
Copy link

Summary

This pull request introduces the ability for users to generate uppercase hexadecimal unique IDs when creating a device ID from a byte array (such as a MAC address).

The motivation for this change comes from my own usage. I have several existing Arduino sensors that use this library where the unique ID was manually set as an uppercase string from the MAC address. To maintain consistency and keep years of historical data in Home Assistant, I could not switch to the more convenient setUniqueId(byte[] mac, ...) function because it only produces lowercase output.

This change adds a non-breaking option to generate uppercase output, providing more flexibility for both new and existing users who require a specific format.

Changes Made

To achieve this while maintaining full backward compatibility, the following changes were implemented:

  • HAUtils::byteArrayToStr: Overloaded the function to accept an optional bool uppercase parameter. The original function now calls this new overload with false to ensure existing behavior is unchanged.
  • HADevice::setUniqueId: Similarly, overloaded the function to accept an optional bool uppercase parameter, exposing the new functionality to the end-user.
  • Changelog: Added an entry to CHANGELOG.md for this new feature.

Contributor Checklist

  • The code change is implemented.
  • An entry has been added to CHANGELOG.md.
  • I have tested this on my own hardware (Arduino UNO R4 Minima + Ethernet Shield) and it works as expected.

This enhancement is fully tested and documented. I look forward to your feedback!

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