Skip to content

Commit

Permalink
Fix for H5178 Temp sensor (#870)
Browse files Browse the repository at this point in the history
  • Loading branch information
damonaw authored Oct 15, 2024
1 parent b511d19 commit 6798973
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@
"type": "string",
"description": "Enter the 23/26 digit Govee Device ID to begin (e.g. 12:AB:A1:C5:A8:99:D2:17).",
"minLength": 23,
"maxLength": 23
"maxLength": 26
},
"ignoreDevice": {
"type": "boolean",
Expand Down
8 changes: 6 additions & 2 deletions lib/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,9 @@ export default class {
// Format device id
if (!httpDevice.device.includes(':')) {
// Eg converts abcd1234abcd1234 to AB:CD:12:34:AB:CD:12:34
httpDevice.device = httpDevice.device.replace(/..\B/g, '$&:').toUpperCase()
// For sensors with an add on sensor like H5178
// Eg converts abcd1234abcd1234_1 to AB:CD:12:34:AB:CD:12:34_1
httpDevice.device = httpDevice.device.replace(/([a-zA-Z0-9]{2})(?=[a-zA-Z0-9])/g, "$&:").toUpperCase()
}

// Check it's not a user-ignored device
Expand Down Expand Up @@ -1239,7 +1241,9 @@ export default class {
// Reformat the device id
if (!device.device.includes(':')) {
// Eg converts abcd1234abcd1234 to AB:CD:12:34:AB:CD:12:34
device.device = device.device.replace(/..\B/g, '$&:').toUpperCase()
// For sensors with an add on sensor like H5178
// Eg converts abcd1234abcd1234_1 to AB:CD:12:34:AB:CD:12:34_1
device.device = device.device.replace(/([a-zA-Z0-9]{2})(?=[a-zA-Z0-9])/g, "$&:").toUpperCase()
}

// Generate the UIID from which we can match our Homebridge accessory
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function parseDeviceId(deviceId) {
return deviceId
.toString()
.toUpperCase()
.replace(/[^A-F0-9:]+/g, '')
.replace(/[^A-F0-9_:]+/g, '')
}

function parseError(err, hideStack = []) {
Expand Down

0 comments on commit 6798973

Please sign in to comment.