setSmartElectricitySleep method

Future<bool> setSmartElectricitySleep(
  1. int enable, {
  2. int timeout = 5,
  3. int electricityThreshold = 50,
})

Implementation

Future<bool> setSmartElectricitySleep(int enable,
    {int timeout = 5, int electricityThreshold = 50}) async {
  bool ret = await _command.writeCgi(
      "trans_cmd_string.cgi?cmd=2106&command=18&Smart_Electricity_Sleep_Switch=$enable&Smart_Electricity_Threshold=$electricityThreshold&",
      timeout: timeout);
  if (ret) {
    CommandResult result =
        await _command.waitCommandResult((int cmd, Uint8List data) {
      if (cmd == 24785) {
        String str = utf8.decode(data);
        return str.contains("cmd=2106;") && str.contains("command=18;");
      }
      return false;
    }, timeout);
    if (result.isSuccess == true) {
      Map data = result.getMap();
      return data["result"] == "0";
    }
  }
  return false;
}