paramGetByCloudId method
Implementation
Future<Object?> paramGetByCloudId({
required CommandDataSource dataSource,
required List<int> cloudIds,
String? dataSourceUid,
}) async {
final normalizedCloudIds =
cloudIds.where((id) => id >= 0).take(7).toList(growable: false);
if (normalizedCloudIds.isEmpty) {
return null;
}
// TODO(Taras): Update once firmware team adds the endpoint
// final response = await sendCommand<ParamGetByCloudIdReply>(
// ParamGetByCloudIdBleCommandTx(
// dataSource: dataSource,
// dataSourceUid: dataSourceUid,
// cloudIds: normalizedCloudIds,
// ),
// );
// if (response == null || response.hasErrors) {
// return null;
// }
// return paramGetForPath(
// pathToRead: response.pathToRead,
// );
// XXX Remove the code below once the endpoint is available
// since response from ParamGetByCloudId should contain the path
final nowEpochSeconds = DateTime.now().millisecondsSinceEpoch ~/ 1000;
for (int offset = 0; offset <= 10; offset++) {
final timestamp = nowEpochSeconds - offset;
final payload = await paramGetForPath(
pathToRead: 's/h/2/$timestamp',
);
if (payload != null) {
return payload;
}
}
return null;
}