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

Generate UUID1 from MAC address #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/Twinkly.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ class Twinkly {
return this.requestService.get("gestalt", false)
.then(json => {
this.name = json.device_name;
this.uuid = json.uuid;
if (json.uuid == "00000000-0000-0000-0000-000000000000") {
this.uuid = `00000000-0000-1000-8000-${json.mac.replaceAll(":", "")}`;

Choose a reason for hiding this comment

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

I would suggest to just use zeroes instead of the '1000' and the '8000' sequence in the time-stamp part, and ignore 'versions' etc.

Choose a reason for hiding this comment

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

Please add .toUpper() to prettify the output as it is in the twinkly controllers

Choose a reason for hiding this comment

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

replaceAl(":" ... must be replace(/:/g ... , since we need to support node.js v14

} else {
this.uuid = json.uuid
}
this.model = json.product_code;
this.serialNumber = json.hw_id;
this.ledCount = json.number_of_led;
Expand Down