Using the Local Home SDK developer preview for Google Assistant, I'm receiving a TypeError
from my application during IDENTIFY
that was previously working correctly. The error is claiming that UdpScanData
is not a valid string when I try to decode the payload.
Example code:
const device = identifyRequest.inputs[0].payload.device;
const response = Buffer.from(device.udpScanData, "hex");
How do I access the UDP discovery payload?
In the 0.2.0 update to the developer preview SDK, we have migrated the UdpScanData
parameter to be an interface instead of just a type alias for string
(see the updated reference docs) to improve consistency with the other scan data types.
To access the response payload for a UDP scan in the latest SDK, update your package.json
dependencies to use v0.2.0:
{
...
"dependencies": {
"@google/local-home-sdk": "^0.2.0"
}
}
Then, access the payload using the new data
property:
const device = identifyRequest.inputs[0].payload.device;
const scanData = device.udpScanData;
const response = Buffer.from(scanData.data, "hex");