getHomeDevices method
Retrieves a list of devices associated with a specific home ID.
Example Usage:
List<ThingSmartDeviceModel> devices = await getHomeDevices(homeId: 123);
Inputs:
homeId
(required): The ID of the home for which to retrieve the devices.
Outputs:
- A list of
ThingSmartDeviceModel
objects representing the devices associated with the specified home ID. If there are no devices or an error occurs, an empty list is returned.
Implementation
Future<List<ThingSmartDeviceModel>> getHomeDevices({
required num homeId,
}) async {
try {
assert(homeId > 0, "homeId must be greater than 0");
var res =
await methodChannel.invokeListMethod<dynamic>('getHomeDevices', {
"homeId": homeId,
});
if (res == null) return [];
return List<ThingSmartDeviceModel>.from(
res.map(
(e) => ThingSmartDeviceModel.fromJson(e.cast<String, dynamic>())),
);
} on PlatformException catch (e) {
_log(e);
return [];
}
}