Skip to content

Commit 53769b7

Browse files
committed
Add debug for unknown products
1 parent d220117 commit 53769b7

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

.changeset/grumpy-apricots-beg.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"homebridge-hatch-baby-rest": minor
3+
---
4+
5+
Add `debug` option which logs unknown product details

packages/homebridge-hatch-baby-rest/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ The Hatch sounds machines use WiFi to directly interact with Hatch's api. This a
4040
]
4141
}
4242
```
43+
44+
### Device Discovery
45+
46+
If you have a new device which is not yet supported, you will see a message like `Unsupported Product Found: restoreV4`. In this case, add `"debug": true` to your config and restart homebridge. This will log the device information and IoT state to the console. Please open an issue with this information and we will see if we can add support for your device.

packages/homebridge-hatch-baby-rest/api.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import { BehaviorSubject } from 'rxjs'
1616
import { IotDevice } from './iot-device'
1717
import { debounceTime } from 'rxjs/operators'
1818

19-
export interface ApiConfig extends EmailAuth {}
19+
export interface ApiConfig extends EmailAuth {
20+
debug?: boolean
21+
}
2022

2123
const knownProducts = [
2224
Product.restPlus,
@@ -180,6 +182,36 @@ export class HatchBabyApi {
180182
!ignoredProducts.includes(product)
181183
) {
182184
logInfo('Unsupported Product Found: ' + product)
185+
186+
if (this.config.debug) {
187+
const debugDevices = createDevices(product, IotDevice)
188+
for (const device of debugDevices) {
189+
try {
190+
logInfo(`Debug info for ${product} ${device.info.name}:`)
191+
logInfo(
192+
JSON.stringify(
193+
{
194+
...device.info,
195+
id: '***',
196+
macAddress: '***',
197+
thingName: '***',
198+
memberId: '***',
199+
email: '***',
200+
},
201+
null,
202+
2,
203+
),
204+
)
205+
logInfo(`State for ${product} ${device.info.name}:`)
206+
logInfo(JSON.stringify(await device.getCurrentState(), null, 2))
207+
} catch (e) {
208+
logError(
209+
`Failed to get debug info for ${product} ${device.info.name}`,
210+
)
211+
logError(e)
212+
}
213+
}
214+
}
183215
}
184216
}
185217

0 commit comments

Comments
 (0)